Permalink
Browse files

Fix order of PersistentTreeMap's kvreduce

We need an in-order traversal to make stuff happen in sorted order. So
rather than self/left/right, we do left/self/right.

Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
  • Loading branch information...
1 parent 0e3a535 commit 3c22b53f94f583bfda6b59c97310de82595e993c @amalloy amalloy committed with stuarthalloway Aug 10, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/jvm/clojure/lang/PersistentTreeMap.java
@@ -537,15 +537,15 @@ Node balanceRight(Node parent){
abstract Node replace(Object key, Object val, Node left, Node right);
public Object kvreduce(IFn f, Object init){
- init = f.invoke(init, key(), val());
- if(RT.isReduced(init))
- return ((IDeref)init).deref();
-
if(left() != null){
init = left().kvreduce(f, init);
if(RT.isReduced(init))
return ((IDeref)init).deref();
}
+ init = f.invoke(init, key(), val());
+ if(RT.isReduced(init))
+ return ((IDeref)init).deref();
+
if(right() != null){
init = right().kvreduce(f, init);
if(RT.isReduced(init))

0 comments on commit 3c22b53

Please sign in to comment.