Skip to content

Commit

Permalink
Issue ehcache#693 Rotate hashcode to better spread simple hashcodes t…
Browse files Browse the repository at this point in the history
…hrough the map. This incurs a slight performance penalty on single-key operations, but improves random sample selection perf
  • Loading branch information
chrisdennis committed Dec 7, 2015
1 parent 0341acd commit 50971a9
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import java.io.ObjectStreamField;
import java.io.Serializable;
import static java.lang.Integer.rotateLeft;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.AbstractMap;
Expand Down Expand Up @@ -671,6 +672,7 @@ Node<K,V> find(int h, Object k) {
* never be used in index calculations because of table bounds.
*/
static final int spread(int h) {
h = rotateLeft(h, 1);
return (h ^ (h >>> 16)) & HASH_BITS;
}

Expand Down

0 comments on commit 50971a9

Please sign in to comment.