Skip to content

Commit 980f3de

Browse files
committed
Refactor lexMagicPoundLiteral
1 parent 9635b73 commit 980f3de

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

Sources/SwiftParser/Lexer/Cursor.swift

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,16 +1188,13 @@ extension Lexer.Cursor {
11881188

11891189
extension Lexer.Cursor {
11901190
mutating func lexMagicPoundLiteral() -> Lexer.Result {
1191-
let start = self
1192-
var clone = self
1191+
var tmp = self
11931192
// Scan for [a-zA-Z]+ to see what we match.
1194-
if let peeked = clone.peek(), Unicode.Scalar(peeked).isAsciiIdentifierStart {
1195-
repeat {
1196-
_ = clone.advance()
1197-
} while clone.peek().map { Unicode.Scalar($0) }?.isAsciiIdentifierContinue == true
1193+
while let peeked = tmp.peek(), Unicode.Scalar(peeked).isAsciiIdentifierStart {
1194+
_ = tmp.advance()
11981195
}
11991196

1200-
let literal = start.text(upTo: clone)
1197+
let literal = self.text(upTo: tmp)
12011198

12021199
let kind: RawTokenKind
12031200
switch literal {
@@ -1220,7 +1217,7 @@ extension Lexer.Cursor {
12201217
}
12211218

12221219
// If we found something specific, return it.
1223-
self = clone
1220+
self = tmp
12241221
return Lexer.Result(kind)
12251222
}
12261223
}

0 commit comments

Comments
 (0)