aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/html/template/css.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/html/template/css.go')
-rw-r--r--libgo/go/html/template/css.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/libgo/go/html/template/css.go b/libgo/go/html/template/css.go
index 1587af8..eb92fc9 100644
--- a/libgo/go/html/template/css.go
+++ b/libgo/go/html/template/css.go
@@ -7,6 +7,7 @@ package template
import (
"bytes"
"fmt"
+ "strings"
"unicode"
"unicode/utf8"
)
@@ -156,7 +157,7 @@ func isCSSSpace(b byte) bool {
// cssEscaper escapes HTML and CSS special characters using \<hex>+ escapes.
func cssEscaper(args ...interface{}) string {
s, _ := stringify(args...)
- var b bytes.Buffer
+ var b strings.Builder
r, w, written := rune(0), 0, 0
for i := 0; i < len(s); i += w {
// See comment in htmlEscaper.
@@ -168,6 +169,9 @@ func cssEscaper(args ...interface{}) string {
default:
continue
}
+ if written == 0 {
+ b.Grow(len(s))
+ }
b.WriteString(s[written:i])
b.WriteString(repl)
written = i + w