Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6486197
Votes 0
Synopsis ConcurrentHashMap.get should check key identity before equality
Category java:classes_util_concurrent
Reported Against
Release Fixed
State 5-Cause Known, request for enhancement
Priority: 5-Very Low
Related Bugs
Submit Date 25-OCT-2006
Description
A DESCRIPTION OF THE REQUEST :
The HashMap implementation short circuits the case of the same key which avoids the potentially more costly equals() comparison at the cost of an extra comparison.



JUSTIFICATION :
Faster when using common keys

ACTUAL -
Current 1.6 HashMap:

if (e.hash == hash && ((k = e.key) == key || key.equals(k)))


Current 1.6 ConcurrentHashMap:

if (e.hash == hash && key.equals(e.key))
Posted Date : 2006-10-25 16:08:04.0
Work Around
N/A
Evaluation
I can think of no reason why such an optimization 
would not apply to both HashMap and ConcurrentHashMap,
as the submitter suggests.

Many equals methods first check for identity themselves,
so there is often a very small amount of double work being
done when optimizing this way.  But more and more,
comparing two values in registers is considered "free".
Posted Date : 2006-10-25 17:16:49.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang