From 85bdb11ca4c274a08df6d923050116db31a7a860 Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 22 Feb 2006 15:16:58 +0000 Subject: [PATCH] optimization: less ArrayList garbage creation! --- weaver/src/org/aspectj/weaver/Shadow.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/Shadow.java b/weaver/src/org/aspectj/weaver/Shadow.java index 2436a6c0e..e9b256027 100644 --- a/weaver/src/org/aspectj/weaver/Shadow.java +++ b/weaver/src/org/aspectj/weaver/Shadow.java @@ -16,6 +16,7 @@ package org.aspectj.weaver; import java.io.DataInputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -49,7 +50,7 @@ public abstract class Shadow { private Member matchingSignature; private ResolvedMember resolvedSignature; protected final Shadow enclosingShadow; - protected List mungers = new ArrayList(1); + protected List mungers = Collections.EMPTY_LIST; public int shadowId = nextShadowID++; // every time we build a shadow, it gets a new id @@ -442,7 +443,10 @@ public abstract class Shadow { public void addMunger(ShadowMunger munger) { - if (checkMunger(munger)) this.mungers.add(munger); + if (checkMunger(munger)) { + if (mungers==Collections.EMPTY_LIST) mungers = new ArrayList(); + this.mungers.add(munger); + } } public final void implement() { -- 2.39.5