Skip to content

Commit e08e2fc

Browse files
committed
[Parser] Add first path to StringSegmentSyntax.appendUnescapedLiteralValue()
If the segment doesn't have '\' in it. We don't need to go back to Lexer to get the unescaped chanacters.
1 parent 5886def commit e08e2fc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Sources/SwiftParser/StringLiteralRepresentedLiteralValue.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ extension StringSegmentSyntax {
7272
precondition(!hasError, "appendUnescapedLiteralValue relies on properly parsed literals")
7373

7474
let rawText = content.rawText
75+
if !rawText.contains("\\") {
76+
// Fast path. No escape sequence.
77+
output.append(String(syntaxText: rawText))
78+
return
79+
}
7580

7681
rawText.withBuffer { buffer in
7782
var cursor = Lexer.Cursor(input: buffer, previous: 0)

0 commit comments

Comments
 (0)