aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/string.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-11-11 17:05:02 -0500
committerRuss Cox <rsc@golang.org>2014-11-11 17:05:02 -0500
commit1e2d2f09470a2be58a98420b4cecae731b156ee8 (patch)
tree4e787523cc5b7e166ff675e1d3da6b1da2207170 /src/runtime/string.go
parentd98553a72782efb2d96c6d6f5e12869826a56779 (diff)
downloadgo-1e2d2f09470a2be58a98420b4cecae731b156ee8.tar.gz
go-1e2d2f09470a2be58a98420b4cecae731b156ee8.zip
[dev.cc] runtime: convert memory allocator and garbage collector to Go
The conversion was done with an automated tool and then modified only as necessary to make it compile and run. [This CL is part of the removal of C code from package runtime. See golang.org/s/dev.cc for an overview.] LGTM=r R=r CC=austin, dvyukov, golang-codereviews, iant, khr https://golang.org/cl/167540043
Diffstat (limited to 'src/runtime/string.go')
-rw-r--r--src/runtime/string.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/runtime/string.go b/src/runtime/string.go
index 0809f89bc1..0845c94e24 100644
--- a/src/runtime/string.go
+++ b/src/runtime/string.go
@@ -225,7 +225,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)
@@ -255,9 +255,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 {
@@ -296,3 +293,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
+}