• Russ Cox's avatar
    runtime: reduce slice growth during append to 2x · 32fddadd
    Russ Cox authored
    The new inlined code for append assumed that it could pass the
    desired new cap to growslice, not the number of new elements.
    But growslice still interpreted the argument as the number of new elements,
    making it always grow by >2x (more precisely, 2x+1 rounded up
    to the next malloc block size). At the time, I had intended to change
    the other callers to use the new cap as well, but it's too late for that.
    Instead, introduce growslice_n for the old callers and keep growslice
    for the inlined (common case) caller.
    
    Fixes #11403.
    
    Filed #11419 to merge them.
    
    Change-Id: I1338b1e5b352f3be4e43641f44b652ef7195251b
    Reviewed-on: https://go-review.googlesource.com/11541Reviewed-by: 's avatarAustin Clements <austin@google.com>
    32fddadd
builtin.go 12 KB