You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Antti Koivunen <an...@users.sourceforge.net> on 2002/03/04 16:20:09 UTC
[Patch] AbstractCache: Lazy event instantiation
This simple patch will considerably improve the performance in case
there are no cache listeners.
(: A ;)
--
Antti Koivunen (Mr.) <an...@users.sf.net>
---------------------------------------------
The song of life might not be a simple one,
but there's plenty of room for improvisation.
---------------------------------------------
Re: [Patch] AbstractCache: Lazy event instantiation
Posted by Eung-ju Park <co...@apache.org>.
Applied Thanks.
----- Original Message -----
From: "Antti Koivunen" <an...@users.sourceforge.net>
To: "Avalon Developers List" <av...@jakarta.apache.org>
Sent: Tuesday, March 05, 2002 12:43 AM
Subject: Re: [Patch] AbstractCache: Lazy event instantiation
> For Mozilla, '*.patch' apparently means 'text/html', so here's the same
> thing renamed to '*.patch.txt', just in case.
>
> (: A ;)
>
> Antti Koivunen wrote:
> > This simple patch will considerably improve the performance in case
> > there are no cache listeners.
> >
> > (: A ;)
> >
>
----------------------------------------------------------------------------
----
> Index: AbstractCache.java
> ===================================================================
> RCS file:
/home/cvspublic/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/ex
calibur/cache/AbstractCache.java,v
> retrieving revision 1.6
> diff -u -r1.6 AbstractCache.java
> --- AbstractCache.java 17 Jan 2002 15:47:05 -0000 1.6
> +++ AbstractCache.java 4 Mar 2002 15:24:28 -0000
> @@ -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>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [Patch] AbstractCache: Lazy event instantiation
Posted by Antti Koivunen <an...@users.sourceforge.net>.
For Mozilla, '*.patch' apparently means 'text/html', so here's the same
thing renamed to '*.patch.txt', just in case.
(: A ;)
Antti Koivunen wrote:
> This simple patch will considerably improve the performance in case
> there are no cache listeners.
>
> (: A ;)
>