diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-06-21 14:14:58 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-06-21 14:14:58 +0000 |
commit | c9b236e5cafaea9d09ff8102140c72eb3d70e302 (patch) | |
tree | daa083891ba7e3c96f4ac7419562dc67146822a6 /libgo/runtime | |
parent | 050e182a757bdf227a7e2425f06f9e2fd4dff8cb (diff) | |
download | gcc-c9b236e5cafaea9d09ff8102140c72eb3d70e302.zip gcc-c9b236e5cafaea9d09ff8102140c72eb3d70e302.tar.gz gcc-c9b236e5cafaea9d09ff8102140c72eb3d70e302.tar.bz2 |
compiler: open code string slice expressions
Currently a string slice expression is implemented with a runtime
call __go_string_slice. Change it to open code it, which is more
efficient, and allows the backend to further optimize it.
Also omit the write barrier for length-only update (i.e.
s = s[:n]).
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/182540
From-SVN: r272549
Diffstat (limited to 'libgo/runtime')
-rw-r--r-- | libgo/runtime/go-strslice.c | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/libgo/runtime/go-strslice.c b/libgo/runtime/go-strslice.c deleted file mode 100644 index d51c249..0000000 --- a/libgo/runtime/go-strslice.c +++ /dev/null @@ -1,30 +0,0 @@ -/* go-strslice.c -- the go string slice function. - - Copyright 2009 The Go Authors. All rights reserved. - Use of this source code is governed by a BSD-style - license that can be found in the LICENSE file. */ - -#include "runtime.h" - -String -__go_string_slice (String s, intgo start, intgo end) -{ - intgo len; - String ret; - - len = s.len; - if (end == -1) - end = len; - if (start > len || end < start || end > len) - runtime_panicstring ("string index out of bounds"); - ret.len = end - start; - // If the length of the new string is zero, the str field doesn't - // matter, so just set it to nil. This avoids the problem of - // s.str + start pointing just past the end of the string, - // which may keep the next memory block alive unnecessarily. - if (ret.len == 0) - ret.str = nil; - else - ret.str = s.str + start; - return ret; -} |