added a fast path to decodeArgAppend when the arg doesnt contain encoded chars

This commit is contained in:
Aliaksandr Valialkin
2017-06-20 13:40:15 +03:00
parent c0de95e84b
commit 2db9429ff7
2 changed files with 26 additions and 0 deletions
+6
View File
@@ -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 == '%' {