From bedc502d33e852d2aef5113b26ff3bb4d5b4bf1f Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sun, 26 Feb 2012 15:02:14 -0600 Subject: [PATCH] Set the listeners list back to null if all listeners are removed from it --- runtime/Java/src/org/antlr/v4/runtime/Parser.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/runtime/Java/src/org/antlr/v4/runtime/Parser.java b/runtime/Java/src/org/antlr/v4/runtime/Parser.java index 7fa0cfb6a..b5940bf0a 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/Parser.java +++ b/runtime/Java/src/org/antlr/v4/runtime/Parser.java @@ -175,10 +175,17 @@ public abstract class Parser extends Recognizer public void removeParseListener(ParseListener l) { if ( l==null ) return; - if ( _parseListeners!=null ) _parseListeners.remove(l); + if ( _parseListeners!=null ) { + _parseListeners.remove(l); + if (_parseListeners.isEmpty()) { + _parseListeners = null; + } + } } - public void removeParseListeners() { if ( _parseListeners!=null ) _parseListeners.clear(); } + public void removeParseListeners() { + _parseListeners = null; + } public void triggerEnterRuleEvent() { for (ParseListener l : _parseListeners) {