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

use append([]byte, string) special case #1

Closed
wants to merge 1 commit into from
Closed

use append([]byte, string) special case #1

wants to merge 1 commit into from

Conversation

alicebob
Copy link

From the specs:

As a special case, copy also accepts a destination argument assignable to type []byte with a source argument of a string type. This form copies the bytes from the string into the byte slice.
https://golang.org/ref/spec#Appending_and_copying_slices

Doesn't seem faster or slower, but is nice to use, and makes it easier for the compiler to be smart.

@valyala
Copy link
Owner

valyala commented Nov 28, 2015

Thanks for the suggestion. Already done in the commit 4aac41a .

@valyala valyala closed this Nov 28, 2015
@valyala
Copy link
Owner

valyala commented Nov 28, 2015

Btw, append(byte, string..) is 2x faster than the previous version according to BenchmarkAppendBytesStr.

valyala pushed a commit that referenced this pull request Dec 27, 2015
stokito pushed a commit to stokito/fasthttp that referenced this pull request Jan 8, 2022
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