Skip to content

strings: Builder causes unnecessary allocation on Reset() #24716

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions