Skip to content

Commit

Permalink
[Swift] Remove pointless do block from LexerATNSimulator.
Browse files Browse the repository at this point in the history
Remove pointless do block from LexerATNSimulator.  This is a translation
from Java of a try/finally block, but we have the finally clause in a
defer block so we don't need the do block.
  • Loading branch information
ewanmellor committed Nov 11, 2017
1 parent 9e143d7 commit 8a48a8c
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions runtime/Swift/Sources/Antlr4/atn/LexerATNSimulator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,23 @@ open class LexerATNSimulator: ATNSimulator {

open func match(_ input: CharStream, _ mode: Int) throws -> Int {
LexerATNSimulator.match_calls += 1

self.mode = mode
var mark = input.mark()
do {
self.startIndex = input.index()
self.prevAccept.reset()
var dfa = decisionToDFA[mode]
defer {
try! input.release(mark)
}

if dfa.s0 == nil {
return try matchATN(input)
} else {
return try execATN(input, dfa.s0!)
}
defer {
try! input.release(mark)
}

self.startIndex = input.index()
self.prevAccept.reset()
let dfa = decisionToDFA[mode]

if let s0 = dfa.s0 {
return try execATN(input, s0)
}
else {
return try matchATN(input)
}
}

override
Expand Down

0 comments on commit 8a48a8c

Please sign in to comment.