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

Avoid using strings.Split #1501

Merged
merged 2 commits into from Nov 6, 2023
Merged

Avoid using strings.Split #1501

merged 2 commits into from Nov 6, 2023

Conversation

tmthrgd
Copy link
Collaborator

@tmthrgd tmthrgd commented Nov 6, 2023

strings.Split has to allocate for the return slice. This allocation was wasteful in ever case it was used in this library.

Instead we use the new strings.Cut and other string manipulation where appropriate. This tends to lead to cleaner and more eadable code in addition to the benefits this has on the garbage collector.

strings.Split has to allocate for the return slice. This allocation
was wasteful in ever case it was used in this library.

Instead we use the new strings.Cut and other string manipulation where
appropriate. This tends to lead to cleaner and more readable code in
addition to the benefits this has on the garbage collector.
This doesn't need to call strings.TrimPrefix twice.
@tmthrgd tmthrgd requested a review from miekg as a code owner November 6, 2023 05:13
@tmthrgd tmthrgd changed the title Strings.split Avoid using strings.Split Nov 6, 2023
@miekg miekg merged commit 02e9e72 into miekg:master Nov 6, 2023
4 checks passed
@tmthrgd tmthrgd deleted the strings.Split branch November 6, 2023 09:45
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