aboutsummaryrefslogtreecommitdiff
path: root/src/strings/example_test.go
diff options
context:
space:
mode:
authorJulien Cretel <jub0bsinthecloud@gmail.com>2025-05-12 12:40:36 +0000
committerGopher Robot <gobot@golang.org>2025-05-12 07:41:07 -0700
commitc0eb7ab3062fae802639545770f6a897d75b0085 (patch)
tree08d07c893621d1849b6e94534e79303d8c1d5bcc /src/strings/example_test.go
parentc57b0d6c7e54284c8967530153774dbc62190b00 (diff)
downloadgo-c0eb7ab3062fae802639545770f6a897d75b0085.tar.xz
bytes, strings: micro-optimize EqualFold
The first loop leaves the lengths of the two arguments unchanged. Take advantage of this invariant in the loop's condition. Here are some benchmark results (no change to allocations): goos: darwin goarch: amd64 pkg: strings cpu: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz │ old │ new │ │ sec/op │ sec/op vs base │ EqualFold/Tests-8 240.0n ± 4% 245.1n ± 5% ~ (p=0.516 n=20) EqualFold/ASCII-8 11.50n ± 1% 11.04n ± 0% -3.96% (p=0.000 n=20) EqualFold/UnicodePrefix-8 102.1n ± 0% 102.2n ± 0% ~ (p=0.455 n=20) EqualFold/UnicodeSuffix-8 90.14n ± 0% 89.80n ± 1% ~ (p=0.113 n=20) geomean 71.00n 70.60n -0.56% Change-Id: I1f6d1df8a0398f9493692f59d7369c3f0fbba436 GitHub-Last-Rev: 9508ee26ad3cadcbb5e532a731b2553ba900f2b1 GitHub-Pull-Request: golang/go#73672 Reviewed-on: https://go-review.googlesource.com/c/go/+/671756 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/strings/example_test.go')
0 files changed, 0 insertions, 0 deletions