Commit 90c21fa
net/textproto: eliminate some bounds checks
This change lifts bounds checks out of loops in the trim function.
Here are some benchmark results (no change to allocations):
goos: darwin
goarch: amd64
pkg: net/textproto
cpu: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
│ old │ new │
│ sec/op │ sec/op vs base │
ReadMIMEHeader/client_headers-8 3.531µ ± 3% 3.506µ ± 1% ~ (p=0.068 n=20)
ReadMIMEHeader/server_headers-8 2.409µ ± 0% 2.384µ ± 1% -1.02% (p=0.000 n=20)
Uncommon-8 545.2n ± 1% 536.7n ± 0% -1.58% (p=0.000 n=20)
geomean 1.667µ 1.649µ -1.10%
Change-Id: Ia6d4ac516497fd3521122ce9b97173a285b61e12
GitHub-Last-Rev: 580f35a
GitHub-Pull-Request: #75126
Reviewed-on: https://go-review.googlesource.com/c/go/+/698715
Reviewed-by: Cherry Mui <[email protected]>
Reviewed-by: Tobias Klauser <[email protected]>
Reviewed-by: Sean Liao <[email protected]>
Auto-Submit: Sean Liao <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Carlos Amedee <[email protected]>1 parent e47d88b commit 90c21fa
1 file changed
+4
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
114 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | | - | |
| 118 | + | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
| |||
0 commit comments