diff options
Diffstat (limited to 'src/runtime/string.go')
-rw-r--r-- | src/runtime/string.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/runtime/string.go b/src/runtime/string.go index 882281605..e01bc3b84 100644 --- a/src/runtime/string.go +++ b/src/runtime/string.go @@ -221,7 +221,7 @@ func rawbyteslice(size int) (b []byte) { // rawruneslice allocates a new rune slice. The rune slice is not zeroed. func rawruneslice(size int) (b []rune) { - if uintptr(size) > maxmem/4 { + if uintptr(size) > _MaxMem/4 { gothrow("out of memory") } mem := goroundupsize(uintptr(size) * 4) @@ -251,9 +251,6 @@ func gostringsize(n int) string { return s } -//go:noescape -func findnull(*byte) int - func gostring(p *byte) string { l := findnull(p) if l == 0 { @@ -292,3 +289,12 @@ func contains(s, t string) bool { func hasprefix(s, t string) bool { return len(s) >= len(t) && s[:len(t)] == t } + +func goatoi(s string) int { + n := 0 + for len(s) > 0 && '0' <= s[0] && s[0] <= '9' { + n = n*10 + int(s[0]) - '0' + s = s[1:] + } + return n +} |