diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2017-06-20 13:40:15 +0300 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2017-06-20 13:40:15 +0300 |
commit | 2db9429ff782eb3b4e7cae05c92d6463ea6fac3c (patch) | |
tree | d44604cb0a82982beedc18f653b155e578915101 /args.go | |
parent | Added AppendUnquotedArg - the complementary function to AppendQuotedArg (diff) | |
download | fasthttp-2db9429ff782eb3b4e7cae05c92d6463ea6fac3c.tar.gz fasthttp-2db9429ff782eb3b4e7cae05c92d6463ea6fac3c.tar.bz2 fasthttp-2db9429ff782eb3b4e7cae05c92d6463ea6fac3c.zip |
added a fast path to decodeArgAppend when the arg doesnt contain encoded chars
Diffstat (limited to 'args.go')
-rw-r--r-- | args.go | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -458,6 +458,12 @@ func decodeArg(dst, src []byte, decodePlus bool) []byte { } 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 + return append(dst, src...) + } + + // slow path for i, n := 0, len(src); i < n; i++ { c := src[i] if c == '%' { |