Skip to content

Commit

Permalink
Imporve AppendHTMLEscape fast path
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyunhao116 committed Mar 16, 2022
1 parent 8f5e51f commit ada1bcb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bytesconv.go
Expand Up @@ -19,10 +19,10 @@ import (

// AppendHTMLEscape appends html-escaped s to dst and returns the extended dst.
func AppendHTMLEscape(dst []byte, s string) []byte {
if strings.IndexByte(s, '&') < 0 &&
strings.IndexByte(s, '<') < 0 &&
if strings.IndexByte(s, '<') < 0 &&
strings.IndexByte(s, '>') < 0 &&
strings.IndexByte(s, '"') < 0 &&
strings.IndexByte(s, '&') < 0 &&
strings.IndexByte(s, '\'') < 0 {

// fast path - nothing to escape
Expand Down

0 comments on commit ada1bcb

Please sign in to comment.