From eda95f74787b3353961099446aacf88769a3eb84 Mon Sep 17 00:00:00 2001 From: Terence Parr Date: Sat, 28 Jul 2012 10:34:34 -0700 Subject: [PATCH] DFA cache on again; dropped from 25 to 16M!!! --- .../Java/src/org/antlr/v4/runtime/atn/ATNConfigSet.java | 7 +++---- .../Java/src/org/antlr/v4/runtime/atn/ATNSimulator.java | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfigSet.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfigSet.java index ed9428eb4..c23e9475e 100755 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfigSet.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNConfigSet.java @@ -269,13 +269,12 @@ public class ATNConfigSet implements Set { */ protected boolean readonly = false; - /** Track every config we add */ -// public final LinkedHashMap configToContext; - /** All configs but hashed by (s, i, _, pi) not incl context */ + /** All configs but hashed by (s, i, _, pi) not incl context. Wiped out + * when we go readonly as this set becomes a DFA state. + */ public ConfigHashSet configLookup; /** Track the elements as they are added to the set; supports get(i) */ - // too hard to keep in sync public final ArrayList configs = new ArrayList(7); // TODO: these fields make me pretty uncomfortable but nice to pack up info together, saves recomputation diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNSimulator.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNSimulator.java index fd212f82e..d5e13d344 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/ATNSimulator.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ATNSimulator.java @@ -51,8 +51,8 @@ public abstract class ATNSimulator { * fill this during closure() since there are lots of contexts that * pop up but are not used ever again. It also greatly slows down closure(). */ - protected final PredictionContextCache sharedContextCache = null; - //new PredictionContextCache("shared DFA state context cache"); + protected final PredictionContextCache sharedContextCache = + new PredictionContextCache("shared DFA state context cache"); /** This context cache tracks all context graphs used during a single * ATN-based prediction operation. There will be significant context graph