Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stdlib] Add split() to StringRef #2705

Open
wants to merge 11 commits into
base: nightly
Choose a base branch
from

Conversation

fknfilewalker
Copy link
Contributor

This PR adds a split() function to StringRef and delegates String.split() to it

Signed-off-by: Lukas Lipp <llipp@cg.tuwien.ac.at>
@fknfilewalker fknfilewalker requested review from a team as code owners May 17, 2024 11:47
Signed-off-by: Lukas Lipp <llipp@cg.tuwien.ac.at>
Signed-off-by: Lukas Lipp <llipp@cg.tuwien.ac.at>
Signed-off-by: Lukas Lipp <llipp@cg.tuwien.ac.at>
Signed-off-by: Lukas Lipp <llipp@cg.tuwien.ac.at>
@JoeLoser JoeLoser self-assigned this May 21, 2024
Signed-off-by: Lukas Lipp <15105596+fknfilewalker@users.noreply.github.com>
@fknfilewalker
Copy link
Contributor Author

Would it be better to first count the occurrence of the delimiter to properly reserve space?

fknfilewalker and others added 5 commits May 21, 2024 23:22
Signed-off-by: Lukas Lipp <15105596+fknfilewalker@users.noreply.github.com>
Signed-off-by: Lukas Lipp <15105596+fknfilewalker@users.noreply.github.com>
Signed-off-by: Lukas Lipp <llipp@cg.tuwien.ac.at>
Signed-off-by: Lukas Lipp <llipp@cg.tuwien.ac.at>
Signed-off-by: Lukas Lipp <llipp@cg.tuwien.ac.at>
@@ -223,6 +223,47 @@ fn test_stringref_from_dtypepointer() raises:
assert_equal(a, b)


fn test_stringref_split() raises:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion Should we put this test in stdlib/test/builtin/test_stringref.mojo instead?

@JoeLoser
Copy link
Collaborator

Would it be better to first count the occurrence of the delimiter to properly reserve space?

Would this require two passes through the input string then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants