create listener set on demand to save memory

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1124 379699f6-c40d-0410-875b-85095c16579e
branch_1_1
jochen 25 years ago
parent 4b8022a00e
commit 43a8e3ea9d
  1. 7
      jode/jode/obfuscator/FieldIdentifier.java.in

@ -44,7 +44,7 @@ public class FieldIdentifier extends Identifier{
* The FieldChangeListener that should be notified if a * The FieldChangeListener that should be notified if a
* write to this field is found. * write to this field is found.
*/ */
private Collection fieldListeners = new HashSet(); private Collection fieldListeners;
public FieldIdentifier(ClassIdentifier clazz, FieldInfo info) { public FieldIdentifier(ClassIdentifier clazz, FieldInfo info) {
super(info.getName()); super(info.getName());
@ -106,6 +106,8 @@ public class FieldIdentifier extends Identifier{
public void addFieldListener(Identifier ident) { public void addFieldListener(Identifier ident) {
if (ident == null) if (ident == null)
throw new NullPointerException(); throw new NullPointerException();
if (fieldListeners == null)
fieldListeners = new HashSet();
if (!fieldListeners.contains(ident)) if (!fieldListeners.contains(ident))
fieldListeners.add(ident); fieldListeners.add(ident);
} }
@ -115,6 +117,9 @@ public class FieldIdentifier extends Identifier{
return; return;
notConstant = true; notConstant = true;
if (fieldListeners == null)
return;
for (Iterator i = fieldListeners.iterator(); i.hasNext(); ) for (Iterator i = fieldListeners.iterator(); i.hasNext(); )
Main.getClassBundle().analyzeIdentifier((Identifier) i.next()); Main.getClassBundle().analyzeIdentifier((Identifier) i.next());
fieldListeners = null; fieldListeners = null;

Loading…
Cancel
Save