fix corruption of old revisioins in PersistentSet

In PersistentSet.remove, we were modifying the child node in place
instead of making a copy to update, which would corrupt older
revisions.  This commit ensures that we always create a copy if
necessary.
This commit is contained in:
Joel Dice 2010-07-30 12:23:41 -06:00
parent 4034a219d0
commit f0129665c6

View File

@ -212,9 +212,11 @@ public class PersistentSet <T> implements Iterable <T> {
Node<T> child; Node<T> child;
if (dead.left != NullNode) { if (dead.left != NullNode) {
child = dead.left; child = new Node(dead.left);
} else if (dead.right != NullNode) {
child = new Node(dead.right);
} else { } else {
child = dead.right; child = NullNode;
} }
if (ancestors == null) { if (ancestors == null) {
@ -453,6 +455,7 @@ public class PersistentSet <T> implements Iterable <T> {
return new Path(false, s.value, p.root, s.next); return new Path(false, s.value, p.root, s.next);
} }
} }
private static class Node <T> { private static class Node <T> {
public T value; public T value;
public Node left; public Node left;