Skip to content

Commit

Permalink
Merge pull request #5 from jordanlewis/transientfix
Browse files Browse the repository at this point in the history
Apply PersistentHashMap.transient fix from mainline
  • Loading branch information
krukow committed Aug 19, 2012
2 parents 114abef + c2a5d02 commit 8c1e182
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/com/trifork/clj_ds/PersistentHashMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -1037,8 +1037,7 @@ public INode without(AtomicReference<Thread> edit, int shift, int hash, Object k
return editAndSet(edit, 2*idx+1, n);
if (bitmap == bit)
return null;
removedLeaf.val = removedLeaf;
return editAndRemovePair(edit, bit, idx);
return editAndRemovePair(edit, bit, idx);
}
if(Util.equals(key, keyOrNull)) {
removedLeaf.val = removedLeaf;
Expand Down Expand Up @@ -1193,7 +1192,9 @@ public int findIndex(Object key){
private HashCollisionNode ensureEditable(AtomicReference<Thread> edit){
if(this.edit == edit)
return this;
return new HashCollisionNode(edit, hash, count, array);
Object[] newArray = new Object[2*(count+1)]; // make room for next assoc
System.arraycopy(array, 0, newArray, 0, 2*count);
return new HashCollisionNode(edit, hash, count, newArray);
}

private HashCollisionNode ensureEditable(AtomicReference<Thread> edit, int count, Object[] array){
Expand Down Expand Up @@ -1249,6 +1250,7 @@ public INode without(AtomicReference<Thread> edit, int shift, int hash, Object k
int idx = findIndex(key);
if(idx == -1)
return this;
removedLeaf.val = removedLeaf;
if(count == 1)
return null;
HashCollisionNode editable = ensureEditable(edit);
Expand Down Expand Up @@ -1451,4 +1453,4 @@ public ISeq next() {
}
}

}
}

0 comments on commit 8c1e182

Please sign in to comment.