You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Working as intended. Since it's aliasing the contents of a byte slice to a string when returning the result, it cannot reuse the data and must abandon it on reset. Perhaps the answer is just not to use strings.Builder for this case. It's not a solution to all problems, just an alternative.
What version of Go are you using (
go version
)?1.10
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?Any
What did you do?
Spotted a performance degradation after switching from bytes.Buffer to strings.Builder.
https://golang.org/src/bytes/buffer.go#L95
https://golang.org/src/strings/builder.go#L53
What did you expect to see?
strings.Builder reusing the allocated array after Reset().
What did you see instead?
Unnecessary memory allocations. A lot of them.
The text was updated successfully, but these errors were encountered: