diff options
Diffstat (limited to 'syntax')
-rw-r--r-- | syntax/quote.go | 5 | ||||
-rw-r--r-- | syntax/scan.go | 3 |
2 files changed, 3 insertions, 5 deletions
diff --git a/syntax/quote.go b/syntax/quote.go index d31eb2a..cc9a8d0 100644 --- a/syntax/quote.go +++ b/syntax/quote.go @@ -7,7 +7,6 @@ package syntax // Starlark quoted string utilities. import ( - "bytes" "fmt" "strconv" "strings" @@ -95,7 +94,7 @@ func unquote(quoted string) (s string, triple bool, err error) { // Otherwise process quoted string. // Each iteration processes one escape sequence along with the // plain text leading up to it. - var buf bytes.Buffer + buf := new(strings.Builder) for { // Remove prefix before escape sequence. i := strings.IndexAny(quoted, unquoteChars) @@ -204,7 +203,7 @@ func quote(unquoted string, triple bool) string { q = `"""` } - var buf bytes.Buffer + buf := new(strings.Builder) buf.WriteString(q) for i := 0; i < len(unquoted); i++ { diff --git a/syntax/scan.go b/syntax/scan.go index 7fbc5d6..5b3fcbc 100644 --- a/syntax/scan.go +++ b/syntax/scan.go @@ -7,7 +7,6 @@ package syntax // A lexical scanner for Starlark. import ( - "bytes" "fmt" "io" "io/ioutil" @@ -832,7 +831,7 @@ func (sc *scanner) scanString(val *tokenValue, quote rune) Token { // A triple-quoted string literal may span multiple // gulps of REPL input; it is the only such token. // Thus we must avoid {start,end}Token. - var raw bytes.Buffer + raw := new(strings.Builder) // Copy the prefix, e.g. r''' or """ (see startToken). raw.Write(sc.token[:len(sc.token)-len(sc.rest)]) |