Commit 0656da91 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

fmt: hold on to all free buffers, regardless of size

This code made sense before fmt switched to using sync.Pool, but a
sync.Pool clears all items on GC, so not reusing something based on
size is just a waste of memory.

Change-Id: I201312b0ee6c572ff3c0ffaf71e42623a160d23f
Reviewed-on: https://go-review.googlesource.com/21480Reviewed-by: 's avatarRob Pike <r@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 163ff700
...@@ -132,10 +132,6 @@ func newPrinter() *pp { ...@@ -132,10 +132,6 @@ func newPrinter() *pp {
// free saves used pp structs in ppFree; avoids an allocation per invocation. // free saves used pp structs in ppFree; avoids an allocation per invocation.
func (p *pp) free() { func (p *pp) free() {
// Don't hold on to pp structs with large buffers.
if cap(p.buf) > 1024 {
return
}
p.buf = p.buf[:0] p.buf = p.buf[:0]
p.arg = nil p.arg = nil
p.value = reflect.Value{} p.value = reflect.Value{}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment