From 662c05c2960e1ae8873a4d2bbb92a011612176e5 Mon Sep 17 00:00:00 2001 From: tyltr Date: Tue, 19 Apr 2022 10:20:35 +0800 Subject: [PATCH] optimize --- args.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/args.go b/args.go index 7c55943651..844d9318f2 100644 --- a/args.go +++ b/args.go @@ -579,13 +579,16 @@ func decodeArgAppend(dst, src []byte) []byte { // The function is copy-pasted from decodeArgAppend due to the performance // reasons only. func decodeArgAppendNoPlus(dst, src []byte) []byte { - if bytes.IndexByte(src, '%') < 0 { + idx := bytes.IndexByte(src, '%') + if idx < 0 { // fast path: src doesn't contain encoded chars return append(dst, src...) + } else { + dst = append(dst, src[:idx]...) } // slow path - for i := 0; i < len(src); i++ { + for i := idx; i < len(src); i++ { c := src[i] if c == '%' { if i+2 >= len(src) {