From e3d25122db3f75867b8016189177a49b63d60769 Mon Sep 17 00:00:00 2001 From: tyltr Date: Wed, 20 Apr 2022 00:39:32 +0800 Subject: [PATCH] optimize (#1272) --- 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) {