I was looking around the Clojure source code and noticed that the persistent immutable collections caches their hash codes.
The java doc says the following about the equals method: (http:// download.oracle.com/javase/1.4.2/docs/api/java/lang/Object.html) "If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result." So I was thinking, wouldn't it be possible to use the cached hash code to rule out cases of equals where equals returns false? public boolean equals(Object obj){ ... if (_hash != -1 && hashCode() != obj.hashCode()) { return false; } ... } This might of cause result in an extra call to hashCode(), so I don't know if it is worth it. Maybe some internal functionality could be added, to ask the collections if their hash code has been cached. What are your thoughts? Kind regards Sune Simonsen -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en