aboutsummaryrefslogtreecommitdiff
path: root/args.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2017-06-20 18:19:36 +0300
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2017-06-20 18:19:36 +0300
commit6ac0fd1a910c94aefb171ae56941833831e7c7fe (patch)
tree2a9995b687aad3016d1784f30a3cbe34e35f1e40 /args.go
parentadded a fast path to decodeArgAppend when the arg doesnt contain encoded chars (diff)
downloadfasthttp-6ac0fd1a910c94aefb171ae56941833831e7c7fe.tar.gz
fasthttp-6ac0fd1a910c94aefb171ae56941833831e7c7fe.tar.bz2
fasthttp-6ac0fd1a910c94aefb171ae56941833831e7c7fe.zip
use more clear decodeArgAppend instead of misleading decodeArg
Diffstat (limited to 'args.go')
-rw-r--r--args.go14
1 files changed, 5 insertions, 9 deletions
diff --git a/args.go b/args.go
index 78401be..b7ac464 100644
--- a/args.go
+++ b/args.go
@@ -428,15 +428,15 @@ func (s *argsScanner) next(kv *argsKV) bool {
case '=':
if isKey {
isKey = false
- kv.key = decodeArg(kv.key, s.b[:i], true)
+ kv.key = decodeArgAppend(kv.key[:0], s.b[:i], true)
k = i + 1
}
case '&':
if isKey {
- kv.key = decodeArg(kv.key, s.b[:i], true)
+ kv.key = decodeArgAppend(kv.key[:0], s.b[:i], true)
kv.value = kv.value[:0]
} else {
- kv.value = decodeArg(kv.value, s.b[k:i], true)
+ kv.value = decodeArgAppend(kv.value[:0], s.b[k:i], true)
}
s.b = s.b[i+1:]
return true
@@ -444,19 +444,15 @@ func (s *argsScanner) next(kv *argsKV) bool {
}
if isKey {
- kv.key = decodeArg(kv.key, s.b, true)
+ kv.key = decodeArgAppend(kv.key[:0], s.b, true)
kv.value = kv.value[:0]
} else {
- kv.value = decodeArg(kv.value, s.b[k:], true)
+ kv.value = decodeArgAppend(kv.value[:0], s.b[k:], true)
}
s.b = s.b[len(s.b):]
return true
}
-func decodeArg(dst, src []byte, decodePlus bool) []byte {
- return decodeArgAppend(dst[:0], src, decodePlus)
-}
-
func decodeArgAppend(dst, src []byte, decodePlus bool) []byte {
if bytes.IndexByte(src, '%') < 0 && (!decodePlus || bytes.IndexByte(src, '+') < 0) {
// fast path: src doesn't contain encoded chars