diff options
author | Sergey Ponomarev <stokito@gmail.com> | 2022-06-06 09:46:49 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-06 08:46:49 +0200 |
commit | 66cd5022fdfb02e619e1b556d1e55fe1f42dac90 (patch) | |
tree | 83a59d3c2e0b1503e1220b17e05f84fc6904fe7f /args.go | |
parent | Response.ContentEncoding(): store as field and avoid using Header.SetCanonica... (diff) | |
download | fasthttp-66cd5022fdfb02e619e1b556d1e55fe1f42dac90.tar.gz fasthttp-66cd5022fdfb02e619e1b556d1e55fe1f42dac90.tar.bz2 fasthttp-66cd5022fdfb02e619e1b556d1e55fe1f42dac90.zip |
header.go Referer() optimize (#1313)
* args.go GetBool(): use switch with string casting
This should be optimized by Go compiler itself so the b2s() call is not needed.
It was previously done by this but changed in
1e7885eb56cdf4c6f550e143b0dbd3acc82a4137
* header.go Referer() optimize
Use direct peekArgBytes() instead of PeekBytes() that will check for special headers
* header_timing_test.go BenchmarkRequestHeaderPeekBytesSpecialHeader
The old BenchmarkRequestHeaderPeekBytesCanonical and BenchmarkRequestHeaderPeekBytesNonCanonical are in fact just measured the header normalization.
But it's anyway is benchmarked separately.
Results was almost the same: 1.5 ns/op.
Instead, let's reuse the benches to find a difference between peeking of special (Host, CT) and custom headers.
Diffstat (limited to 'args.go')
-rw-r--r-- | args.go | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -343,7 +343,7 @@ func (a *Args) GetUfloatOrZero(key string) float64 { // true is returned for "1", "t", "T", "true", "TRUE", "True", "y", "yes", "Y", "YES", "Yes", // otherwise false is returned. func (a *Args) GetBool(key string) bool { - switch b2s(a.Peek(key)) { + switch string(a.Peek(key)) { // Support the same true cases as strconv.ParseBool // See: https://github.com/golang/go/blob/4e1b11e2c9bdb0ddea1141eed487be1a626ff5be/src/strconv/atob.go#L12 // and Y and Yes versions. |