File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -1504,12 +1504,12 @@ func (s *Scanner) scanTemplateAndSetTokenValue(shouldEmitInvalidEscapeError bool
1504
1504
startedWithBacktick := s .char () == '`'
1505
1505
s .pos ++
1506
1506
start := s .pos
1507
- contents := ""
1507
+ b := strings. Builder {}
1508
1508
var token ast.Kind
1509
1509
for {
1510
1510
ch := s .char ()
1511
1511
if ch < 0 || ch == '`' {
1512
- contents += s .text [start :s .pos ]
1512
+ b . WriteString ( s .text [start :s .pos ])
1513
1513
if ch == '`' {
1514
1514
s .pos ++
1515
1515
} else {
@@ -1520,32 +1520,32 @@ func (s *Scanner) scanTemplateAndSetTokenValue(shouldEmitInvalidEscapeError bool
1520
1520
break
1521
1521
}
1522
1522
if ch == '$' && s .charAt (1 ) == '{' {
1523
- contents += s .text [start :s .pos ]
1523
+ b . WriteString ( s .text [start :s .pos ])
1524
1524
s .pos += 2
1525
1525
token = core .IfElse (startedWithBacktick , ast .KindTemplateHead , ast .KindTemplateMiddle )
1526
1526
break
1527
1527
}
1528
1528
if ch == '\\' {
1529
- contents += s .text [start :s .pos ]
1530
- contents += s .scanEscapeSequence (EscapeSequenceScanningFlagsString | core .IfElse (shouldEmitInvalidEscapeError , EscapeSequenceScanningFlagsReportErrors , 0 ))
1529
+ b . WriteString ( s .text [start :s .pos ])
1530
+ b . WriteString ( s .scanEscapeSequence (EscapeSequenceScanningFlagsString | core .IfElse (shouldEmitInvalidEscapeError , EscapeSequenceScanningFlagsReportErrors , 0 ) ))
1531
1531
start = s .pos
1532
1532
continue
1533
1533
}
1534
1534
// Speculated ECMAScript 6 Spec 11.8.6.1:
1535
1535
// <CR><LF> and <CR> LineTerminatorSequences are normalized to <LF> for Template Values
1536
1536
if ch == '\r' {
1537
- contents += s .text [start :s .pos ]
1537
+ b . WriteString ( s .text [start :s .pos ])
1538
1538
s .pos ++
1539
1539
if s .char () == '\n' {
1540
1540
s .pos ++
1541
1541
}
1542
- contents += "\n "
1542
+ b . WriteString ( "\n " )
1543
1543
start = s .pos
1544
1544
continue
1545
1545
}
1546
1546
s .pos ++
1547
1547
}
1548
- s .tokenValue = contents
1548
+ s .tokenValue = b . String ()
1549
1549
return token
1550
1550
}
1551
1551
You can’t perform that action at this time.
0 commit comments