From bace9523eed9bc695310cd327b19ecdf7aa44612 Mon Sep 17 00:00:00 2001 From: Dmitriy Vyukov Date: Mon, 27 Jan 2014 15:11:12 +0400 Subject: 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/malloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/pkg/runtime/malloc.h') diff --git a/src/pkg/runtime/malloc.h b/src/pkg/runtime/malloc.h index 8122b4b0b8..4146299223 100644 --- a/src/pkg/runtime/malloc.h +++ b/src/pkg/runtime/malloc.h @@ -273,6 +273,7 @@ extern MStats mstats; // making new objects in class i int32 runtime·SizeToClass(int32); +uintptr runtime·roundupsize(uintptr); extern int32 runtime·class_to_size[NumSizeClasses]; extern int32 runtime·class_to_allocnpages[NumSizeClasses]; extern int8 runtime·size_to_class8[1024/8 + 1]; -- cgit v1.3-5-g9baa