Replace string concatenation with StringBuilder (#23021)
Этот коммит содержится в:
@@ -628,7 +628,7 @@ func MergeInlineText(inlines []Inline) []Inline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Unescape(markdown string) string {
|
func Unescape(markdown string) string {
|
||||||
ret := ""
|
var ret strings.Builder
|
||||||
|
|
||||||
position := 0
|
position := 0
|
||||||
for position < len(markdown) {
|
for position < len(markdown) {
|
||||||
@@ -637,27 +637,27 @@ func Unescape(markdown string) string {
|
|||||||
switch c {
|
switch c {
|
||||||
case '\\':
|
case '\\':
|
||||||
if position+1 < len(markdown) && isEscapableByte(markdown[position+1]) {
|
if position+1 < len(markdown) && isEscapableByte(markdown[position+1]) {
|
||||||
ret += string(markdown[position+1])
|
ret.WriteByte(markdown[position+1])
|
||||||
position += 2
|
position += 2
|
||||||
} else {
|
} else {
|
||||||
ret += `\`
|
ret.WriteString(`\`)
|
||||||
position++
|
position++
|
||||||
}
|
}
|
||||||
case '&':
|
case '&':
|
||||||
position++
|
position++
|
||||||
if semicolon := strings.IndexByte(markdown[position:], ';'); semicolon == -1 {
|
if semicolon := strings.IndexByte(markdown[position:], ';'); semicolon == -1 {
|
||||||
ret += "&"
|
ret.WriteString("&")
|
||||||
} else if s := CharacterReference(markdown[position : position+semicolon]); s != "" {
|
} else if s := CharacterReference(markdown[position : position+semicolon]); s != "" {
|
||||||
position += semicolon + 1
|
position += semicolon + 1
|
||||||
ret += s
|
ret.WriteString(s)
|
||||||
} else {
|
} else {
|
||||||
ret += "&"
|
ret.WriteString("&")
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
ret += string(c)
|
ret.WriteRune(c)
|
||||||
position += cSize
|
position += cSize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
return ret.String()
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user