Skip to content

Commit 2e2925c

Browse files
author
Joel Dice
committed
fix backwards logic in treeMapInsert which prevented correct balancing
1 parent 15ea90c commit 2e2925c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/util.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ treeAdd(Thread* t, object path)
143143
if (treeNodeRed
144144
(t, treeNodeRight(t, pairFirst(t, pairSecond(t, ancestors)))))
145145
{
146-
setTreeNodeRed(t, pairFirst(t, ancestors), true);
146+
setTreeNodeRed(t, pairFirst(t, ancestors), false);
147147

148148
object n = cloneTreeNode
149149
(t, treeNodeRight(t, pairFirst(t, pairSecond(t, ancestors))));
@@ -154,7 +154,7 @@ treeAdd(Thread* t, object path)
154154
(t, treeNodeRight
155155
(t, pairFirst(t, pairSecond(t, ancestors))), false);
156156

157-
setTreeNodeRed(t, pairFirst(t, pairSecond(t, ancestors)), false);
157+
setTreeNodeRed(t, pairFirst(t, pairSecond(t, ancestors)), true);
158158

159159
new_ = pairFirst(t, pairSecond(t, ancestors));
160160
ancestors = pairSecond(t, pairSecond(t, ancestors));
@@ -195,7 +195,7 @@ treeAdd(Thread* t, object path)
195195
if (treeNodeRed
196196
(t, treeNodeLeft(t, pairFirst(t, pairSecond(t, ancestors)))))
197197
{
198-
setTreeNodeRed(t, pairFirst(t, ancestors), true);
198+
setTreeNodeRed(t, pairFirst(t, ancestors), false);
199199

200200
object n = cloneTreeNode
201201
(t, treeNodeLeft(t, pairFirst(t, pairSecond(t, ancestors))));
@@ -206,7 +206,7 @@ treeAdd(Thread* t, object path)
206206
(t, treeNodeLeft
207207
(t, pairFirst(t, pairSecond(t, ancestors))), false);
208208

209-
setTreeNodeRed(t, pairFirst(t, pairSecond(t, ancestors)), false);
209+
setTreeNodeRed(t, pairFirst(t, pairSecond(t, ancestors)), true);
210210

211211
new_ = pairFirst(t, pairSecond(t, ancestors));
212212
ancestors = pairSecond(t, pairSecond(t, ancestors));

0 commit comments

Comments
 (0)