aboutsummaryrefslogtreecommitdiff
path: root/cookie.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-03-10 17:44:58 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-03-10 17:44:58 +0200
commite0eac186523036e28b2c3d15b91e186750cc8d1f (patch)
tree9815d90ffacce3b40bac88fc645cce766d25fe0c /cookie.go
parentIssue #64: properly delete header values via Del call (diff)
downloadfasthttp-e0eac186523036e28b2c3d15b91e186750cc8d1f.tar.gz
fasthttp-e0eac186523036e28b2c3d15b91e186750cc8d1f.tar.bz2
fasthttp-e0eac186523036e28b2c3d15b91e186750cc8d1f.zip
use 'switch string(key) {}' instead of 'switch { case bytes.Equal(key, ...) ... }'. This may improve switch statement's performance
Diffstat (limited to 'cookie.go')
-rw-r--r--cookie.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/cookie.go b/cookie.go
index 7bf921a..90f481d 100644
--- a/cookie.go
+++ b/cookie.go
@@ -240,17 +240,17 @@ func (c *Cookie) ParseBytes(src []byte) error {
if len(kv.key) == 0 && len(kv.value) == 0 {
continue
}
- switch {
- case bytes.Equal(strCookieExpires, kv.key):
+ switch string(kv.key) {
+ case "expires":
v := unsafeBytesToStr(kv.value)
exptime, err := time.ParseInLocation(time.RFC1123, v, time.UTC)
if err != nil {
return err
}
c.expire = exptime
- case bytes.Equal(strCookieDomain, kv.key):
+ case "domain":
c.domain = append(c.domain[:0], kv.value...)
- case bytes.Equal(strCookiePath, kv.key):
+ case "path":
c.path = append(c.path[:0], kv.value...)
}
}