avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject cvs commit: avalon/meta/api/src/java/org/apache/avalon/meta/info Type.java
Date Wed, 07 Apr 2004 03:46:44 GMT
niclas      2004/04/06 20:46:44

  Modified:    meta/api/src/java/org/apache/avalon/meta/info Type.java
  Log:
  Shortcircuit the equals() tests to improve performance.
  
  Revision  Changes    Path
  1.5       +29 -12    avalon/meta/api/src/java/org/apache/avalon/meta/info/Type.java
  
  Index: Type.java
  ===================================================================
  RCS file: /home/cvs/avalon/meta/api/src/java/org/apache/avalon/meta/info/Type.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Type.java	24 Feb 2004 21:35:31 -0000	1.4
  +++ Type.java	7 Apr 2004 03:46:44 -0000	1.5
  @@ -414,32 +414,49 @@
       */
       public boolean equals(Object other)
       {
  -        boolean isEqual = other instanceof Type;
  -        isEqual = isEqual && m_descriptor.equals(((Type)other).m_descriptor);
  -        isEqual = isEqual && m_security.equals(((Type)other).m_security);
  -        isEqual = isEqual && m_configuration.equals(((Type)other).m_configuration);
  -        isEqual = isEqual && m_context.equals(((Type)other).m_context);
  +        if( ! (other instanceof Type )
  +            return false;
  +        Type t = (Type) other;
  +        
  +        if( ! m_descriptor.equals( t.m_descriptor ) )
  +            return false;
  +            
  +        if( ! m_security.equals( t.m_security ) )
  +            return false;
  +            
  +        if( ! m_configuration.equals( t.m_configuration ) )
  +            return false;
  +            
  +        if( ! m_context.equals( t.m_context ) )
  +            return false;
  +            
           for( int i=0; i<m_loggers.length; i++ )
           {
  -            isEqual = isEqual && m_loggers[i].equals(((Type)other).m_loggers[i]);
  +            if( ! m_loggers[i].equals( t.m_loggers[i] ) )
  +                return false;
           }
  +        
           for( int i=0; i<m_services.length; i++ )
           {
  -            isEqual = isEqual && m_services[i].equals(((Type)other).m_services[i]);
  +            if( ! m_services[i].equals( t.m_services[i] ) )
  +                return false;
           }
           for( int i=0; i<m_dependencies.length; i++ )
           {
  -            isEqual = isEqual && m_dependencies[i].equals(((Type)other).m_dependencies[i]);
  +            if( ! m_dependencies[i].equals( t.m_dependencies[i] ) )
  +                return false;
           }
           for( int i=0; i<m_stages.length; i++ )
           {
  -            isEqual = isEqual && m_stages[i].equals(((Type)other).m_stages[i]);
  +            if( m_stages[i].equals( t.m_stages[i] ) )
  +                return false;
           }
           for( int i=0; i<m_extensions.length; i++ )
           {
  -            isEqual = isEqual && m_extensions[i].equals(((Type)other).m_extensions[i]);
  +            if( m_extensions[i].equals( t.m_extensions[i] ) )
  +                return false;
           }
  -        return isEqual;
  +        return true;
       }
   
      /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message