Skip to content

Commit

Permalink
Use let instead of var when it's possible.
Browse files Browse the repository at this point in the history
These usage of `var` instead of `let` causes Swift compiler
warnings.
  • Loading branch information
niw committed Jan 4, 2021
1 parent 547fd7c commit a0536d6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion runtime/Swift/Sources/Antlr4/Lexer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ open class Lexer: Recognizer<LexerATNSimulator>, TokenSource {

// Mark start location in char stream so unbuffered streams are
// guaranteed at least have text of current token
var tokenStartMarker = _input.mark()
let tokenStartMarker = _input.mark()
defer {
// make sure we release marker after match or
// unbuffered char stream will keep buffering
Expand Down
10 changes: 5 additions & 5 deletions runtime/Swift/Sources/Antlr4/atn/LexerATNSimulator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ open class LexerATNSimulator: ATNSimulator {
LexerATNSimulator.match_calls += 1

self.mode = mode
var mark = input.mark()
let mark = input.mark()
defer {
try! input.release(mark)
}
Expand Down Expand Up @@ -609,10 +609,10 @@ open class LexerATNSimulator: ATNSimulator {
return try recog.sempred(nil, ruleIndex, predIndex)
}

var savedCharPositionInLine = charPositionInLine
var savedLine = line
var index = input.index()
var marker = input.mark()
let savedCharPositionInLine = charPositionInLine
let savedLine = line
let index = input.index()
let marker = input.mark()
do {
try consume(input)
defer
Expand Down
2 changes: 1 addition & 1 deletion runtime/Swift/Sources/Antlr4/atn/LexerActionExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public class LexerActionExecutor: Hashable {
///
public func execute(_ lexer: Lexer, _ input: CharStream, _ startIndex: Int) throws {
var requiresSeek: Bool = false
var stopIndex: Int = input.index()
let stopIndex: Int = input.index()
defer {
if requiresSeek {
try! input.seek(stopIndex)
Expand Down
12 changes: 6 additions & 6 deletions runtime/Swift/Sources/Antlr4/atn/ProfilingATNSimulator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ public class ProfilingATNSimulator: ParserATNSimulator {

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

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

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

0 comments on commit a0536d6

Please sign in to comment.