strings: Builder copy check causes a dynamic memory allocation #23382
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
release-blocker
Milestone
What version of Go are you using (
go version
)?go version go1.9.1 darwin/amd64
Does this issue reproduce with the latest release?
N/A
What operating system and processor architecture are you using (
go env
)?What did you do?
Regarding 3058d38
The change causes the
strings.Builder
value to always escape to the heap if any of its methods is called, which means there will be 2 dynamic memory allocations to build a string (one for the byte slice and one for the builder).The intent of this type was to save on memory allocations caused by the use of
bytes.Buffer
, now it seems like it's just as inefficient.Here's a quick benchmark to highlight what I'm talking about:
The text was updated successfully, but these errors were encountered: