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

perfguard/_rules: add sliceClone pattern #185

Merged
merged 1 commit into from Mar 20, 2022

Conversation

quasilyte
Copy link
Owner

For hot paths (o2 level) suggest this rewrite:

append([]byte(str1), str2...)
=>
append(append(make([]byte, 0, len(str1)+len(str2)), str1...), str2...)

This will make the operation work with only 1 allocation instead of 2.

See golang/go#47454

For hot paths (o2 level) suggest this rewrite:

	append([]byte(str1), str2...)
	=>
	append(append(make([]byte, 0, len(str1)+len(str2)), str1...), str2...)

This will make the operation work with only 1 allocation instead of 2.

See golang/go#47454
@quasilyte quasilyte merged commit a894e04 into master Mar 20, 2022
@quasilyte quasilyte deleted the quasilyte/add_slice_clone_pattern branch March 20, 2022 14:29
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

1 participant