mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
bytes: minor optimization to lastIndexFunc
Before and after: BenchmarkTrimSpace 20000000 81.3 ns/op BenchmarkTrimSpace 50000000 58.0 ns/op (most whitespace trimming is ASCII whitespace) Same optimization appeared a handful of other places in this file, but not here. R=golang-dev, dave CC=golang-dev https://golang.org/cl/7305063
This commit is contained in:
parent
7594440ef1
commit
30a9957aac
2 changed files with 11 additions and 1 deletions
|
|
@ -1073,3 +1073,10 @@ func BenchmarkFieldsFunc(b *testing.B) {
|
|||
FieldsFunc(fieldsInput, unicode.IsSpace)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkTrimSpace(b *testing.B) {
|
||||
s := []byte(" Some text. \n")
|
||||
for i := 0; i < b.N; i++ {
|
||||
TrimSpace(s)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue