aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/string.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2018-03-01 22:22:44 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2018-03-01 22:22:51 +0000
commit1fadbc1a76b2d9a11453ef4e21b77c353493ac2c (patch)
tree8e2b488ca5bb3d6a702523cc6707c4d2c5f0d732 /src/runtime/string.go
parentf1fc9da3167e4424935524a1479442d28e9fd72a (diff)
downloadgo-1fadbc1a76b2d9a11453ef4e21b77c353493ac2c.tar.xz
Revert "runtime: use bytes.IndexByte in findnull"
This reverts commit 7365fac2dbd01960268ee051ed03d961258d4ef4. Reason for revert: breaks the build on some architectures, reading unmapped pages? Change-Id: I3a8c02dc0b649269faacea79ecd8213defa97c54 Reviewed-on: https://go-review.googlesource.com/97995 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime/string.go')
-rw-r--r--src/runtime/string.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/runtime/string.go b/src/runtime/string.go
index 0ea162235c..5c83895995 100644
--- a/src/runtime/string.go
+++ b/src/runtime/string.go
@@ -407,9 +407,12 @@ func findnull(s *byte) int {
if s == nil {
return 0
}
- ss := stringStruct{unsafe.Pointer(s), maxAlloc/2 - 1}
- t := *(*string)(unsafe.Pointer(&ss))
- return stringsIndexByte(t, 0)
+ p := (*[maxAlloc/2 - 1]byte)(unsafe.Pointer(s))
+ l := 0
+ for p[l] != 0 {
+ l++
+ }
+ return l
}
func findnullw(s *uint16) int {