From c05b9bc9283a88cde811632980bc854858ab29fd Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 22 Feb 2006 15:22:28 +0000 Subject: [PATCH] optimization: less ArrayList garbage creation! --- weaver/src/org/aspectj/weaver/bcel/BcelShadow.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java index b6b661154..b93d764df 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java @@ -16,6 +16,7 @@ package org.aspectj.weaver.bcel; import java.lang.reflect.Modifier; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -170,11 +171,14 @@ public class BcelShadow extends Shadow { public BcelShadow copyInto(LazyMethodGen recipient, BcelShadow enclosing) { BcelShadow s = new BcelShadow(world, getKind(), getSignature(), recipient, enclosing); - List src = mungers; - List dest = s.mungers; - - for (Iterator i = src.iterator(); i.hasNext(); ) { - dest.add(i.next()); + if (mungers.size()>0) { + List src = mungers; + if (s.mungers==Collections.EMPTY_LIST) s.mungers = new ArrayList(); + List dest = s.mungers; + + for (Iterator i = src.iterator(); i.hasNext(); ) { + dest.add(i.next()); + } } return s; } -- 2.39.5