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
{{ message }}
Repository navigation
strings: (*Builder).Grow should take benefit from sizeclasses #64833
The Grow method on strings.Builder is documented as:
Grow grows b's capacity, if necessary, to guarantee space for another n bytes. After Grow(n), at least n bytes can be written to b without another allocation. If n is negative, Grow panics.
Currently it grows as such:
// grow copies the buffer to a new, larger buffer so that there are at least n// bytes of capacity beyond len(b.buf).func (b*Builder) grow(nint) {
buf:=bytealg.MakeNoZero(2*cap(b.buf) +n)[:len(b.buf)]
copy(buf, b.buf)
b.buf=buf
}
I think that it is backwards compatible to start using sizeclasses in the strings.Builder, and not waste memory while growing.
changed the title [-]strings: strings.Builder.Grow should take benefit from sizeclasses[/-][+]strings: strings.Builder Grow should take benefit from sizeclasses[/+]on Dec 21, 2023
changed the title [-]strings: strings.Builder Grow should take benefit from sizeclasses[/-][+]strings: (*Builder).Grow should take benefit from sizeclasses[/+]on Dec 21, 2023
Activity
[-]strings: strings.Builder.Grow should take benefit from sizeclasses[/-][+]strings: strings.Builder Grow should take benefit from sizeclasses[/+][-]strings: strings.Builder Grow should take benefit from sizeclasses[/-][+]strings: (*Builder).Grow should take benefit from sizeclasses[/+]gopherbot commentedon Dec 21, 2023
Change https://go.dev/cl/552135 mentions this issue:
strings: make use of sizeclasses in (*Builder).Growstrings: make use of sizeclasses in (*Builder).Grow