aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/string.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-11-15 08:00:38 -0500
committerRuss Cox <rsc@golang.org>2014-11-15 08:00:38 -0500
commit0fcf54b3d2bc42a947c65e9a520d078b671f8432 (patch)
tree071014526059897ceef47c43e5a24ddc0a57b636 /src/runtime/string.go
parent9ef4e5610809780555260f386d6e20f3df87c6ce (diff)
parent5fce15a2a3cd94427bb9979d73acf14013ec7f31 (diff)
downloadgo-0fcf54b3d2bc42a947c65e9a520d078b671f8432.tar.xz
[dev.garbage] all: merge dev.cc into dev.garbage
The garbage collector is now written in Go. There is plenty to clean up (just like on dev.cc). all.bash passes on darwin/amd64, darwin/386, linux/amd64, linux/386. TBR=rlh R=austin, rlh, bradfitz CC=golang-codereviews https://golang.org/cl/173250043
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 882281605a..e01bc3b846 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
+}