diff options
| author | Luuk van Dijk <lvd@golang.org> | 2012-06-02 22:50:57 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2012-06-02 22:50:57 -0400 |
| commit | 40af78c19eeceb38407c2b7c2a4d8b685249701f (patch) | |
| tree | b24ef28a18403d64c64670c9dc01aac977dfb4bd /src/pkg | |
| parent | 192550592a24a8ba1e826d11f0426e5889c1a0af (diff) | |
| download | go-40af78c19eeceb38407c2b7c2a4d8b685249701f.tar.xz | |
cmd/gc: inline slice[arr,str] in the frontend (mostly).
R=rsc, ality, rogpeppe, minux.ma, dave
CC=golang-dev
https://golang.org/cl/5966075
Diffstat (limited to 'src/pkg')
| -rw-r--r-- | src/pkg/runtime/slice.c | 143 | ||||
| -rw-r--r-- | src/pkg/runtime/string.goc | 25 |
2 files changed, 0 insertions, 168 deletions
diff --git a/src/pkg/runtime/slice.c b/src/pkg/runtime/slice.c index e5726c93b9..3c7c8be0e9 100644 --- a/src/pkg/runtime/slice.c +++ b/src/pkg/runtime/slice.c @@ -147,149 +147,6 @@ growslice1(SliceType *t, Slice x, int32 newcap, Slice *ret) runtime·memmove(ret->array, x.array, ret->len * t->elem->size); } -// sliceslice(old []any, lb uint64, hb uint64, width uint64) (ary []any); -void -runtime·sliceslice(Slice old, uint64 lb, uint64 hb, uint64 width, Slice ret) -{ - if(hb > old.cap || lb > hb) { - if(debug) { - runtime·prints("runtime.sliceslice: old="); - runtime·printslice(old); - runtime·prints("; lb="); - runtime·printint(lb); - runtime·prints("; hb="); - runtime·printint(hb); - runtime·prints("; width="); - runtime·printint(width); - runtime·prints("\n"); - - runtime·prints("oldarray: nel="); - runtime·printint(old.len); - runtime·prints("; cap="); - runtime·printint(old.cap); - runtime·prints("\n"); - } - runtime·panicslice(); - } - - // new array is inside old array - ret.len = hb - lb; - ret.cap = old.cap - lb; - ret.array = old.array + lb*width; - - FLUSH(&ret); - - if(debug) { - runtime·prints("runtime.sliceslice: old="); - runtime·printslice(old); - runtime·prints("; lb="); - runtime·printint(lb); - runtime·prints("; hb="); - runtime·printint(hb); - runtime·prints("; width="); - runtime·printint(width); - runtime·prints("; ret="); - runtime·printslice(ret); - runtime·prints("\n"); - } -} - -// sliceslice1(old []any, lb uint64, width uint64) (ary []any); -void -runtime·sliceslice1(Slice old, uint64 lb, uint64 width, Slice ret) -{ - if(lb > old.len) { - if(debug) { - runtime·prints("runtime.sliceslice: old="); - runtime·printslice(old); - runtime·prints("; lb="); - runtime·printint(lb); - runtime·prints("; width="); - runtime·printint(width); - runtime·prints("\n"); - - runtime·prints("oldarray: nel="); - runtime·printint(old.len); - runtime·prints("; cap="); - runtime·printint(old.cap); - runtime·prints("\n"); - } - runtime·panicslice(); - } - - // new array is inside old array - ret.len = old.len - lb; - ret.cap = old.cap - lb; - ret.array = old.array + lb*width; - - FLUSH(&ret); - - if(debug) { - runtime·prints("runtime.sliceslice: old="); - runtime·printslice(old); - runtime·prints("; lb="); - runtime·printint(lb); - runtime·prints("; width="); - runtime·printint(width); - runtime·prints("; ret="); - runtime·printslice(ret); - runtime·prints("\n"); - } -} - -// slicearray(old *any, nel uint64, lb uint64, hb uint64, width uint64) (ary []any); -void -runtime·slicearray(byte* old, uint64 nel, uint64 lb, uint64 hb, uint64 width, Slice ret) -{ - if(nel > 0 && old == nil) { - // crash if old == nil. - // could give a better message - // but this is consistent with all the in-line checks - // that the compiler inserts for other uses. - *old = 0; - } - - if(hb > nel || lb > hb) { - if(debug) { - runtime·prints("runtime.slicearray: old="); - runtime·printpointer(old); - runtime·prints("; nel="); - runtime·printint(nel); - runtime·prints("; lb="); - runtime·printint(lb); - runtime·prints("; hb="); - runtime·printint(hb); - runtime·prints("; width="); - runtime·printint(width); - runtime·prints("\n"); - } - runtime·panicslice(); - } - - // new array is inside old array - ret.len = hb-lb; - ret.cap = nel-lb; - ret.array = old + lb*width; - - FLUSH(&ret); - - if(debug) { - runtime·prints("runtime.slicearray: old="); - runtime·printpointer(old); - runtime·prints("; nel="); - runtime·printint(nel); - runtime·prints("; lb="); - runtime·printint(lb); - runtime·prints("; hb="); - runtime·printint(hb); - runtime·prints("; width="); - runtime·printint(width); - runtime·prints("; ret="); - runtime·printslice(ret); - runtime·prints("\n"); - } -} - // copy(to any, fr any, wid uint32) int void runtime·copy(Slice to, Slice fm, uintptr width, int32 ret) diff --git a/src/pkg/runtime/string.goc b/src/pkg/runtime/string.goc index 7e1f8a1e8b..090c4cd20e 100644 --- a/src/pkg/runtime/string.goc +++ b/src/pkg/runtime/string.goc @@ -235,31 +235,6 @@ runtime·strstr(byte *s1, byte *s2) return nil; } -func slicestring(si String, lindex int32, hindex int32) (so String) { - int32 l; - - if(lindex < 0 || lindex > si.len || - hindex < lindex || hindex > si.len) { - runtime·panicslice(); - } - - l = hindex-lindex; - so.str = si.str + lindex; - so.len = l; -} - -func slicestring1(si String, lindex int32) (so String) { - int32 l; - - if(lindex < 0 || lindex > si.len) { - runtime·panicslice(); - } - - l = si.len-lindex; - so.str = si.str + lindex; - so.len = l; -} - func intstring(v int64) (s String) { s = gostringsize(8); s.len = runtime·runetochar(s.str, v); |
