diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2016-03-10 17:44:58 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2016-03-10 17:44:58 +0200 |
commit | e0eac186523036e28b2c3d15b91e186750cc8d1f (patch) | |
tree | 9815d90ffacce3b40bac88fc645cce766d25fe0c /cookie.go | |
parent | Issue #64: properly delete header values via Del call (diff) | |
download | fasthttp-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.go | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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...) } } |