Skip to content

Commit a0536d6

Browse files
committed
Use let instead of var when it's possible.
These usage of `var` instead of `let` causes Swift compiler warnings.
1 parent 547fd7c commit a0536d6

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

runtime/Swift/Sources/Antlr4/Lexer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ open class Lexer: Recognizer<LexerATNSimulator>, TokenSource {
132132

133133
// Mark start location in char stream so unbuffered streams are
134134
// guaranteed at least have text of current token
135-
var tokenStartMarker = _input.mark()
135+
let tokenStartMarker = _input.mark()
136136
defer {
137137
// make sure we release marker after match or
138138
// unbuffered char stream will keep buffering

runtime/Swift/Sources/Antlr4/atn/LexerATNSimulator.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ open class LexerATNSimulator: ATNSimulator {
116116
LexerATNSimulator.match_calls += 1
117117

118118
self.mode = mode
119-
var mark = input.mark()
119+
let mark = input.mark()
120120
defer {
121121
try! input.release(mark)
122122
}
@@ -609,10 +609,10 @@ open class LexerATNSimulator: ATNSimulator {
609609
return try recog.sempred(nil, ruleIndex, predIndex)
610610
}
611611

612-
var savedCharPositionInLine = charPositionInLine
613-
var savedLine = line
614-
var index = input.index()
615-
var marker = input.mark()
612+
let savedCharPositionInLine = charPositionInLine
613+
let savedLine = line
614+
let index = input.index()
615+
let marker = input.mark()
616616
do {
617617
try consume(input)
618618
defer

runtime/Swift/Sources/Antlr4/atn/LexerActionExecutor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public class LexerActionExecutor: Hashable {
149149
///
150150
public func execute(_ lexer: Lexer, _ input: CharStream, _ startIndex: Int) throws {
151151
var requiresSeek: Bool = false
152-
var stopIndex: Int = input.index()
152+
let stopIndex: Int = input.index()
153153
defer {
154154
if requiresSeek {
155155
try! input.seek(stopIndex)

runtime/Swift/Sources/Antlr4/atn/ProfilingATNSimulator.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ public class ProfilingATNSimulator: ParserATNSimulator {
5353

5454
override
5555
public func adaptivePredict(_ input: TokenStream, _ decision: Int,_ outerContext: ParserRuleContext?) throws -> Int {
56-
var outerContext = outerContext
56+
let outerContext = outerContext
5757
self._sllStopIndex = -1
5858
self._llStopIndex = -1
5959
self.currentDecision = decision
60-
var start: Int64 = Int64(Date().timeIntervalSince1970) //System.nanoTime(); // expensive but useful info
61-
var alt: Int = try super.adaptivePredict(input, decision, outerContext)
62-
var stop: Int64 = Int64(Date().timeIntervalSince1970) //System.nanoTime();
60+
let start: Int64 = Int64(Date().timeIntervalSince1970) //System.nanoTime(); // expensive but useful info
61+
let alt: Int = try super.adaptivePredict(input, decision, outerContext)
62+
let stop: Int64 = Int64(Date().timeIntervalSince1970) //System.nanoTime();
6363
decisions[decision].timeInPrediction += (stop - start)
6464
decisions[decision].invocations += 1
6565

66-
var SLL_k: Int64 = Int64(_sllStopIndex - _startIndex + 1)
66+
let SLL_k: Int64 = Int64(_sllStopIndex - _startIndex + 1)
6767
decisions[decision].SLL_TotalLook += SLL_k
6868
decisions[decision].SLL_MinLook = decisions[decision].SLL_MinLook == 0 ? SLL_k : min(decisions[decision].SLL_MinLook, SLL_k)
6969
if SLL_k > decisions[decision].SLL_MaxLook {
@@ -73,7 +73,7 @@ public class ProfilingATNSimulator: ParserATNSimulator {
7373
}
7474

7575
if _llStopIndex >= 0 {
76-
var LL_k: Int64 = Int64(_llStopIndex - _startIndex + 1)
76+
let LL_k: Int64 = Int64(_llStopIndex - _startIndex + 1)
7777
decisions[decision].LL_TotalLook += LL_k
7878
decisions[decision].LL_MinLook = decisions[decision].LL_MinLook == 0 ? LL_k : min(decisions[decision].LL_MinLook, LL_k)
7979
if LL_k > decisions[decision].LL_MaxLook {

0 commit comments

Comments
 (0)