You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by co...@apache.org on 2002/03/04 18:03:16 UTC
cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/cache AbstractCache.java
colus 02/03/04 09:03:16
Modified: src/scratchpad/org/apache/avalon/excalibur/cache
AbstractCache.java
Log:
This simple patch will considerably improve the performance in case
there are no cache listeners.
Submitted by: Antti Koivunen <an...@users.sf.net>
Revision Changes Path
1.7 +12 -2 jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/cache/AbstractCache.java
Index: AbstractCache.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/cache/AbstractCache.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractCache.java 17 Jan 2002 15:47:05 -0000 1.6
+++ AbstractCache.java 4 Mar 2002 17:03:16 -0000 1.7
@@ -11,8 +11,10 @@
import java.util.Iterator;
/**
+ * An abstract superclass for cache implementations.
*
* @author <a href="mailto:colus@apache.org">Eung-ju Park</a>
+ * @author <a href="mailto:anryoshi@users.sf.net">Antti Koivunen</a>
*/
public abstract class AbstractCache
implements Cache
@@ -36,22 +38,30 @@
protected void notifyAdded( final Object key, final Object value )
{
- final CacheEvent event = new CacheEvent( this, key, value );
+ CacheEvent event = null;
final int s = m_listeners.size();
for ( int i = 0; i < s; i++ )
{
+ if ( event == null )
+ {
+ event = new CacheEvent( this, key, value );
+ }
((CacheListener)m_listeners.get( i )).added( event );
}
}
protected void notifyRemoved( final Object key, final Object value )
{
- final CacheEvent event = new CacheEvent( this, key, value );
+ CacheEvent event = null;
final int s = m_listeners.size();
for ( int i = 0; i < s; i++ )
{
+ if ( event == null )
+ {
+ event = new CacheEvent( this, key, value );
+ }
((CacheListener)m_listeners.get( i )).removed( event );
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>