aboutsummaryrefslogtreecommitdiff
path: root/bytesconv.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2017-07-11 10:17:57 +0300
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2017-07-11 10:17:57 +0300
commit52a0993b96f032dea57fa93081d7c0a1aa906430 (patch)
treee6fe0099018c7e3e65e2f82e3ab592ef2c1dcc78 /bytesconv.go
parentadd gramework (#280) (diff)
downloadfasthttp-52a0993b96f032dea57fa93081d7c0a1aa906430.tar.gz
fasthttp-52a0993b96f032dea57fa93081d7c0a1aa906430.tar.bz2
fasthttp-52a0993b96f032dea57fa93081d7c0a1aa906430.zip
Issue #278: more optimizations for normalizeHeaderKey
Diffstat (limited to 'bytesconv.go')
-rw-r--r--bytesconv.go19
1 files changed, 7 insertions, 12 deletions
diff --git a/bytesconv.go b/bytesconv.go
index eb4248a..56d6ca2 100644
--- a/bytesconv.go
+++ b/bytesconv.go
@@ -348,8 +348,9 @@ var toLowerTable = func() [256]byte {
for i := 0; i < 256; i++ {
c := byte(i)
if c >= 'A' && c <= 'Z' {
- a[i] = toLower
+ c += toLower
}
+ a[i] = c
}
return a
}()
@@ -359,23 +360,17 @@ var toUpperTable = func() [256]byte {
for i := 0; i < 256; i++ {
c := byte(i)
if c >= 'a' && c <= 'z' {
- a[i] = 256 - toLower
+ c -= toLower
}
+ a[i] = c
}
return a
}()
-func uppercaseByte(p *byte) {
- *p += toUpperTable[*p]
-}
-
-func lowercaseByte(p *byte) {
- *p += toLowerTable[*p]
-}
-
func lowercaseBytes(b []byte) {
- for i, n := 0, len(b); i < n; i++ {
- lowercaseByte(&b[i])
+ for i := 0; i < len(b); i++ {
+ p := &b[i]
+ *p = toLowerTable[*p]
}
}