Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ private final int hash(Object key) {

public Object get(Object key) {
int hash = hash(key);
int j;
if (hash < NUMBER_LOCKS) j = hash;
else j = Math.abs(hash%NUMBER_LOCKS);
synchronized (locks[j]) {
synchronized (locks[hash % NUMBER_LOCKS]) {
for (Node m = buckets[hash]; m != null; m = m.next) {
if (m.key.equals(key)) return m.value;
}
Expand All @@ -41,10 +38,7 @@ public Object get(Object key) {

public void clear() {
for (int i = 0; i < buckets.length; i++) {
int j;
if (i < NUMBER_LOCKS) j = i;
else j = Math.abs(i%NUMBER_LOCKS);
synchronized (locks[j]) {
synchronized (locks[i % NUMBER_LOCKS) {
buckets[i] = null;
}
}
Expand Down