velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject cvs commit: jakarta-velocity/src/java/org/apache/velocity/util/introspection Introspector.java
Date Tue, 11 Sep 2001 17:31:42 GMT
geirm       01/09/11 10:31:42

  Modified:    src/java/org/apache/velocity/util/introspection
                        Introspector.java
  Log:
  Keeping mind off things.
  
  Changed the name of classByName to cachedClassNames, and changed the
  cache clearing routine to not .clear() the cachedClassNames but just
  make a new one for speed.
  
  Also, it doesn't seem that using a Set would offer any advantage, as AFAIK,
  the standard impls are backed by HashMap or TreeMap anyway...
  
  Revision  Changes    Path
  1.13      +16 -6     jakarta-velocity/src/java/org/apache/velocity/util/introspection/Introspector.java
  
  Index: Introspector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/util/introspection/Introspector.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Introspector.java	2001/09/11 17:14:03	1.12
  +++ Introspector.java	2001/09/11 17:31:42	1.13
  @@ -87,7 +87,7 @@
    * @author <a href="mailto:bob@werken.com">Bob McWhirter</a>
    * @author <a href="mailto:szegedia@freemail.hu">Attila Szegedi</a>
    * @author <a href="mailto:paulo.gaspar@krankikom.de">Paulo Gaspar</a>
  - * @version $Id: Introspector.java,v 1.12 2001/09/11 17:14:03 dlr Exp $
  + * @version $Id: Introspector.java,v 1.13 2001/09/11 17:31:42 geirm Exp $
    */
   public class Introspector
   {
  @@ -102,7 +102,7 @@
       /**
        * Holds the qualified class name to Class object mapping.
        */
  -    private final Map classByName = new HashMap();
  +    private Map cachedClassNames = new HashMap();
   
       /**
        *  Recieves our RuntimeServices object
  @@ -141,7 +141,7 @@
                
               if (classMap == null)
               {
  -                Class cachedClass = (Class) classByName.get( c.getName() );
  +                Class cachedClass = (Class) cachedClassNames.get( c.getName() );
                   
                   if (cachedClass != null)
                   {
  @@ -165,7 +165,7 @@
       {
           ClassMap classMap = new ClassMap(c);        
           classMethodMaps.put(c, classMap);
  -        classByName.put(c.getName(), c);
  +        cachedClassNames.put(c.getName(), c);
   
           return classMap;
       }
  @@ -175,9 +175,19 @@
        * caches
        */
       private void clearCache()
  -    {            
  +    {
  +        /*
  +         *  since we are synchronizing on this
  +         *  object, we have to clear it rather than
  +         *  just dump it.
  +         */            
           classMethodMaps.clear();
  -        classByName.clear();    
  +        
  +        /*
  +         * for speed, we can just make a new one
  +         * and let the old one be GC'd
  +         */
  +        cachedClassNames = new HashMap();
       }
           
       /**
  
  
  

Mime
View raw message