v4: Combine calls to Set.contains and Set.add

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9492]
This commit is contained in:
sharwell 2011-11-30 06:32:33 -08:00
parent 2bbb1ca132
commit befd9ba483
2 changed files with 2 additions and 4 deletions

View File

@ -94,8 +94,7 @@ public class LL1Analyzer {
{
// System.out.println("_LOOK("+s.stateNumber+", ctx="+ctx);
ATNConfig c = new ATNConfig(s, 0, ctx);
if ( lookBusy.contains(c) ) return;
lookBusy.add(c);
if ( !lookBusy.add(c) ) return;
if ( s instanceof RuleStopState ) {
if ( ctx==null ) {

View File

@ -647,8 +647,7 @@ public class ParserATNSimulator<Symbol> extends ATNSimulator {
{
if ( debug ) System.out.println("closure("+config+")");
if ( closureBusy.contains(config) ) return; // avoid infinite recursion
closureBusy.add(config);
if ( !closureBusy.add(config) ) return; // avoid infinite recursion
if ( config.state instanceof RuleStopState ) {
// We hit rule end. If we have context info, use it