From 71eb2aed783decadc14615b6e00d614b0dfbdf6c Mon Sep 17 00:00:00 2001 From: Stephane Bailliez Date: Sat, 22 Jan 2005 22:56:17 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277432 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/zip/ZipEntry.java | 25 ++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/org/apache/tools/zip/ZipEntry.java b/src/main/org/apache/tools/zip/ZipEntry.java index 6847419a5..f4950bc7b 100644 --- a/src/main/org/apache/tools/zip/ZipEntry.java +++ b/src/main/org/apache/tools/zip/ZipEntry.java @@ -400,32 +400,31 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { 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 o * @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 *