diff options
author | Keith Randall <khr@golang.org> | 2023-05-16 15:16:06 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2023-05-16 23:34:59 +0000 |
commit | 6d1c507bfc360ba72ca716bb7cb7bd9105a45af4 (patch) | |
tree | 5df3c47f687f1912f17b538e8dd84883fe91753c /src/runtime/sys_darwin_arm64.s | |
parent | 882cc4d596ef179afecb920138419e694654589a (diff) | |
download | go-git-6d1c507bfc360ba72ca716bb7cb7bd9105a45af4.tar.gz |
slices: for Insert and Replace, grow slices like append does
At least when we're inserting/replacing near the end of a slice, when
we have to grow it use the same multiplicative growth factor that the
runtime uses for append.
Before this CL, we would grow the slice one page (8192 bytes) at a time
for large slices. This would cause O(n^2) work when appending near the
end should only take O(n) work.
This doesn't fix the problem if you insert/replace near the start of the
array, but maybe that doesn't need fixing because it is O(n^2) anyway.
Fixes #60134
Change-Id: If05376bc512ab839769180e5ce4cb929f47363b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/495296
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'src/runtime/sys_darwin_arm64.s')
0 files changed, 0 insertions, 0 deletions