diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2013-07-26 21:17:24 +0400 |
|---|---|---|
| committer | Dmitriy Vyukov <dvyukov@google.com> | 2013-07-26 21:17:24 +0400 |
| commit | f8a850b250655bd26f5da4cfe7299b4a32be28fa (patch) | |
| tree | 8337d4705585d9f8391110098d1d57816ab4d9cf /src/pkg/runtime/string.goc | |
| parent | a0f74093b2f3aa0d8d2b69c881a75f40d296355f (diff) | |
| download | go-f8a850b250655bd26f5da4cfe7299b4a32be28fa.tar.xz | |
runtime: refactor mallocgc
Make it accept type, combine flags.
Several reasons for the change:
1. mallocgc and settype must be atomic wrt GC
2. settype is called from only one place now
3. it will help performance (eventually settype
functionality must be combined with markallocated)
4. flags are easier to read now (no mallocgc(sz, 0, 1, 0) anymore)
R=golang-dev, iant, nightlyone, rsc, dave, khr, bradfitz, r
CC=golang-dev
https://golang.org/cl/10136043
Diffstat (limited to 'src/pkg/runtime/string.goc')
| -rw-r--r-- | src/pkg/runtime/string.goc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/pkg/runtime/string.goc b/src/pkg/runtime/string.goc index 108487d69d..15d690a921 100644 --- a/src/pkg/runtime/string.goc +++ b/src/pkg/runtime/string.goc @@ -45,7 +45,7 @@ gostringsize(intgo l) if(l == 0) return runtime·emptystring; // leave room for NUL for C runtime (e.g., callers of getenv) - s.str = runtime·mallocgc(l+1, FlagNoPointers, 1, 0); + s.str = runtime·mallocgc(l+1, 0, FlagNoPointers|FlagNoZero); s.len = l; s.str[l] = 0; for(;;) { @@ -83,7 +83,7 @@ runtime·gobytes(byte *p, intgo n) { Slice sl; - sl.array = runtime·mallocgc(n, FlagNoPointers, 1, 0); + sl.array = runtime·mallocgc(n, 0, FlagNoPointers|FlagNoZero); sl.len = n; sl.cap = n; runtime·memmove(sl.array, p, n); @@ -250,7 +250,7 @@ func slicebytetostring(b Slice) (s String) { } func stringtoslicebyte(s String) (b Slice) { - b.array = runtime·mallocgc(s.len, FlagNoPointers, 1, 0); + b.array = runtime·mallocgc(s.len, 0, FlagNoPointers|FlagNoZero); b.len = s.len; b.cap = s.len; runtime·memmove(b.array, s.str, s.len); @@ -299,7 +299,7 @@ func stringtoslicerune(s String) (b Slice) { n++; } - b.array = runtime·mallocgc(n*sizeof(r[0]), FlagNoPointers, 1, 0); + b.array = runtime·mallocgc(n*sizeof(r[0]), 0, FlagNoPointers|FlagNoZero); b.len = n; b.cap = n; p = s.str; |
