ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sbaill...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/zip ZipEntry.java
Date Sat, 22 Jan 2005 22:56:18 GMT
sbailliez    2005/01/22 14:56:18

  Modified:    src/main/org/apache/tools/zip ZipEntry.java
  Log:
  Reactivate methods disabled in PR 33049.
  The equals method was a bit lousy and does not have a real meaning, so I keep it clear that
the equals is related to the instance and nothing else. the hashCode method is actually the
most important for performance.
  
  I have yet to find a way to unit test it programmatically as I don't understand the Zip
task impl. at first glance.
  
  Revision  Changes    Path
  1.25      +13 -14    ant/src/main/org/apache/tools/zip/ZipEntry.java
  
  Index: ZipEntry.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/zip/ZipEntry.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- ZipEntry.java	11 Jan 2005 23:09:36 -0000	1.24
  +++ ZipEntry.java	22 Jan 2005 22:56:17 -0000	1.25
  @@ -400,32 +400,31 @@
           this.name = name;
       }
   
  -    /* Two zipentries are not necessarily equal if they have the same name. */
  -    /*
  +    /**
        * Get the hashCode of the entry.
        * This uses the name as the hashcode.
        * @return a hashcode.
        * @since Ant 1.7
        */
  -/*    public int hashCode() {
  +    public int hashCode() {
  +        // this method has severe consequences on performance. We cannot rely
  +        // on the super.hashCode() method since super.getName() always return
  +        // the empty string in the current implemention (there's no setter)
  +        // so it is basically draining the performance of a hashmap lookup
           return getName().hashCode();
       }
  -*/
  -    /*
  -     * The equality method.
   
  +    /**
  +     * The equality method. In this case, the implementation returns 'this == o'
  +     * which is basically the equals method of the Object class.
        * @param o the object to compare to
        * @return true if this object has the same name as <code>o</code>
        * @since Ant 1.7
        */
  -/*    public boolean equals(Object o) {
  -        if (o instanceof ZipEntry) {
  -            ZipEntry other = (ZipEntry) o;
  -            return other.getName().equals(getName());
  -        }
  -        return false;
  +    public boolean equals(Object o) {
  +        return (this == o);
       }
  -*/
  +
       /**
        * Helper for JDK 1.1
        *
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message