bloritsch    2003/07/10 07:41:56

  Modified:    meta/spi/src/java/org/apache/avalon/meta/info
                        Descriptor.java
  Log:
  Simplify the comparison code tremendously, and speed it up as well.  Properties is 
built on Hashtable which properly takes care of these things.
  
  Revision  Changes    Path
  1.3       +6 -23     
avalon-sandbox/meta/spi/src/java/org/apache/avalon/meta/info/Descriptor.java
  
  Index: Descriptor.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/meta/spi/src/java/org/apache/avalon/meta/info/Descriptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Descriptor.java   10 Jul 2003 14:31:03 -0000      1.2
  +++ Descriptor.java   10 Jul 2003 14:41:56 -0000      1.3
  @@ -142,8 +142,7 @@
       {
           if( other instanceof Descriptor )
           {
  -            Descriptor descriptor = (Descriptor) other;
  -            return compare( this, descriptor );
  +            return compare( this, (Descriptor) other );
           }
           return false;
       }
  @@ -169,27 +168,11 @@
   
       private static boolean compare( Descriptor primary, Descriptor secondary )
       {
  -        if( primary.getAttributeNames().length != 
secondary.getAttributeNames().length )
  +        if ( null == primary.m_attributes )
           {
  -            return false;
  +            return null == secondary.m_attributes;
           }
  -        String[] names = primary.getAttributeNames();
  -        for( int i=0; i<names.length; i++ )
  -        {
  -            String v1 = primary.getAttribute( names[i] );
  -            String v2 = secondary.getAttribute( names[i] );
  -            if( v1 == null )
  -            {
  -                if( v2 != null )
  -                {
  -                    return false;
  -                }
  -            }
  -            if( !v1.equals( v2 ) )
  -            {
  -                return false;
  -            }
  -        }
  -        return true;
  +
  +        return primary.m_attributes.equals(secondary.m_attributes);
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to