Skip to content

Commit

Permalink
optimize (#1272)
Browse files Browse the repository at this point in the history
  • Loading branch information
tylitianrui committed Apr 19, 2022
1 parent b40b5a4 commit e3d2512
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions args.go
Expand Up @@ -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) {
Expand Down

0 comments on commit e3d2512

Please sign in to comment.