Merge pull request #12174 from bboreham/builder-range-smaller
labels: shrink stack arrays in Builder.Range
This commit is contained in:
commit
edc8e75c40
|
@ -547,8 +547,8 @@ func (b *Builder) Get(n string) string {
|
|||
// Range calls f on each label in the Builder.
|
||||
func (b *Builder) Range(f func(l Label)) {
|
||||
// Stack-based arrays to avoid heap allocation in most cases.
|
||||
var addStack [1024]Label
|
||||
var delStack [1024]string
|
||||
var addStack [128]Label
|
||||
var delStack [128]string
|
||||
// Take a copy of add and del, so they are unaffected by calls to Set() or Del().
|
||||
origAdd, origDel := append(addStack[:0], b.add...), append(delStack[:0], b.del...)
|
||||
b.base.Range(func(l Label) {
|
||||
|
|
|
@ -601,8 +601,8 @@ func (b *Builder) Get(n string) string {
|
|||
// Range calls f on each label in the Builder.
|
||||
func (b *Builder) Range(f func(l Label)) {
|
||||
// Stack-based arrays to avoid heap allocation in most cases.
|
||||
var addStack [1024]Label
|
||||
var delStack [1024]string
|
||||
var addStack [128]Label
|
||||
var delStack [128]string
|
||||
// Take a copy of add and del, so they are unaffected by calls to Set() or Del().
|
||||
origAdd, origDel := append(addStack[:0], b.add...), append(delStack[:0], b.del...)
|
||||
b.base.Range(func(l Label) {
|
||||
|
|
Loading…
Reference in New Issue