From 89a251e4973eb03a1eed5793d3b05864288b5486 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sun, 30 Jun 2013 15:42:27 -0500 Subject: [PATCH] Simplify ArrayPredictionContext.isEmpty() --- .../src/org/antlr/v4/runtime/atn/ArrayPredictionContext.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ArrayPredictionContext.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ArrayPredictionContext.java index 5540622fe..68fbbc0be 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/ArrayPredictionContext.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ArrayPredictionContext.java @@ -59,8 +59,9 @@ public class ArrayPredictionContext extends PredictionContext { @Override public boolean isEmpty() { - return size()==1 && - returnStates[0]==EMPTY_RETURN_STATE; + // since EMPTY_RETURN_STATE can only appear in the last position, we + // don't need to verify that size==1 + return returnStates[0]==EMPTY_RETURN_STATE; } @Override