Skip to content

Commit 92d0720

Browse files
authored
Only use pool, if needed (#43)
1 parent 51a865b commit 92d0720

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

visitor.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ func (v *treeVisitor) addString(str string, pos token.Pos, typ Type) {
133133
var unquotedStr string
134134
if strings.HasPrefix(str, `"`) || strings.HasPrefix(str, "`") {
135135
var err error
136-
// Reuse strings from pool if possible to avoid allocations
137-
sb := GetStringBuilder()
138-
defer PutStringBuilder(sb)
139-
140136
unquotedStr, err = strconv.Unquote(str)
141137
if err != nil {
138+
// Reuse strings from pool if possible to avoid allocations
139+
sb := GetStringBuilder()
140+
defer PutStringBuilder(sb)
141+
142142
// If unquoting fails, manually strip quotes
143143
// This avoids additional temporary strings
144144
if len(str) >= 2 {

0 commit comments

Comments
 (0)