]> Cypherpunks repositories - gostls13.git/commit
runtime: smarter slice grow
authorDmitriy Vyukov <dvyukov@google.com>
Mon, 27 Jan 2014 11:11:12 +0000 (15:11 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Mon, 27 Jan 2014 11:11:12 +0000 (15:11 +0400)
commitbace9523eed9bc695310cd327b19ecdf7aa44612
tree4681c7cab80d9aa0b49f93db0b7aad22753d485d
parent496c030c506bf1ac18c82ba85d4bcc5031253bdf
runtime: smarter slice grow
When growing slice take into account size of the allocated memory block.
Also apply the same optimization to string->[]byte conversion.
Fixes #6307.

benchmark                    old ns/op    new ns/op    delta
BenchmarkAppendGrowByte        4541036      4434108   -2.35%
BenchmarkAppendGrowString     59885673     44813604  -25.17%

LGTM=khr
R=khr
CC=golang-codereviews, iant, rsc
https://golang.org/cl/53340044
src/pkg/runtime/append_test.go
src/pkg/runtime/malloc.h
src/pkg/runtime/msize.c
src/pkg/runtime/slice.c
src/pkg/runtime/string.goc