From afed3ac34969c21859084b6ddafb229709c5b20b Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 29 Oct 2012 11:39:40 -0500 Subject: [PATCH] Remove unnecessary null checks --- .../v4/runtime/atn/LexerATNSimulator.java | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java index a46aed91f..01b058a63 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java @@ -298,20 +298,18 @@ public class LexerATNSimulator extends ATNSimulator { // that already has lots of edges out of it. e.g., .* in comments. DFAState target = null; ATNConfigSet reach = null; - if (s != null) { - if ( s.edges != null && t < s.edges.length && t > IntStream.EOF ) { - closure = s.configs; - target = s.edges[t]; - if (target == ERROR) { - break; - } - else if (target != null) { - if ( debug ) { - System.out.println("reuse state "+s.stateNumber+ - " edge to "+target.stateNumber); - } - reach = target.configs; + if ( s.edges != null && t < s.edges.length && t > IntStream.EOF ) { + closure = s.configs; + target = s.edges[t]; + if (target == ERROR) { + break; + } + else if (target != null) { + if ( debug ) { + System.out.println("reuse state "+s.stateNumber+ + " edge to "+target.stateNumber); } + reach = target.configs; } } @@ -330,9 +328,7 @@ public class LexerATNSimulator extends ATNSimulator { DFAState from = s != null ? s : addDFAState(closure); // we got nowhere on t, don't throw out this knowledge; it'd // cause a failover from DFA later. - if (from != null) { - addDFAEdge(from, t, ERROR); - } + addDFAEdge(from, t, ERROR); break; // stop when we can't match any more char } @@ -694,7 +690,7 @@ public class LexerATNSimulator extends ATNSimulator { return to; } - if (from == null || to == null || suppressEdge) { + if (suppressEdge) { return to; }