Skip to content

Commit

Permalink
Revert "Refine org.antlr.v4.runtime.atn.ATNConfigSet.remove(int)"
Browse files Browse the repository at this point in the history
This reverts commit 7e4fb3a.
  • Loading branch information
daniellansun committed Dec 22, 2024
1 parent 2931111 commit f6af0ad
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfigSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public boolean add(ATNConfig e, @Nullable PredictionContextCache contextCache) {
return true;
}

for (int i = 0, n = unmerged.size(); i < n; i++) {
for (int i = 0; i < unmerged.size(); i++) {
ATNConfig unmergedConfig = unmerged.get(i);
if (canMerge(e, key, unmergedConfig)) {
unmergedConfig.setOuterContextDepth(Math.max(unmergedConfig.getOuterContextDepth(), e.getOuterContextDepth()));
Expand Down Expand Up @@ -522,15 +522,15 @@ public ATNConfig get(int index) {

public void remove(int index) {
ensureWritable();
final ATNConfig config = configs.get(index);
ATNConfig config = configs.get(index);
configs.remove(config);
long key = getKey(config);
if (mergedConfigs.get(key) == config) {
mergedConfigs.remove(key);
} else {
for (Iterator<ATNConfig> iterator = unmerged.iterator(); iterator.hasNext(); ) {
if (iterator.next() == config) {
iterator.remove();
for (int i = 0; i < unmerged.size(); i++) {
if (unmerged.get(i) == config) {
unmerged.remove(i);
return;
}
}
Expand Down

0 comments on commit f6af0ad

Please sign in to comment.