mirror of
https://github.com/golang/go.git
synced 2025-05-31 23:25:39 +00:00
strconv: use bytealg implementation of IndexByteString
benchmark old ns/op new ns/op delta BenchmarkUnquoteEasy-4 188 79.5 -57.71% BenchmarkUnquoteHard-4 653 622 -4.75% Fixes #23821 Change-Id: I1ebfab1b7f0248fd313de21396e0f8612076aa6d Reviewed-on: https://go-review.googlesource.com/116755 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
0c706fddce
commit
5ddecd1508
@ -6,7 +6,10 @@
|
||||
|
||||
package strconv
|
||||
|
||||
import "unicode/utf8"
|
||||
import (
|
||||
"internal/bytealg"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
const lowerhex = "0123456789abcdef"
|
||||
|
||||
@ -424,12 +427,7 @@ func Unquote(s string) (string, error) {
|
||||
|
||||
// contains reports whether the string contains the byte c.
|
||||
func contains(s string, c byte) bool {
|
||||
for i := 0; i < len(s); i++ {
|
||||
if s[i] == c {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return bytealg.IndexByteString(s, c) != -1
|
||||
}
|
||||
|
||||
// bsearch16 returns the smallest i such that a[i] >= x.
|
||||
|
Loading…
x
Reference in New Issue
Block a user