Permalink
Browse files

Merge pull request #5 from jordanlewis/transientfix

Apply PersistentHashMap.transient fix from mainline
  • Loading branch information...
krukow committed Aug 19, 2012
2 parents 114abef + c2a5d02 commit 8c1e182ee85615faca5ea1a59bf9dac4fbb4d62d
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/main/java/com/trifork/clj_ds/PersistentHashMap.java
@@ -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;
@@ -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){
@@ -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);
@@ -1451,4 +1453,4 @@ public ISeq next() {
}
}
-}
+}

0 comments on commit 8c1e182

Please sign in to comment.