Commit 5ddecd15 authored by Tim Cooper's avatar Tim Cooper Committed by Brad Fitzpatrick

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/116755Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 0c706fdd
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment