Skip to content
Browse files

fix pop! when the tree depth decreases

Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
  • Loading branch information...
1 parent 2ac9319 commit 59ecee6a6f037612b3b1ed2d939f5e0017f2dd11 @cgrand cgrand committed with stuarthalloway May 28, 2010
Showing with 5 additions and 3 deletions.
  1. +1 −1 src/jvm/clojure/lang/PersistentVector.java
  2. +4 −2 test/clojure/test_clojure/transients.clj
View
2 src/jvm/clojure/lang/PersistentVector.java
@@ -625,7 +625,7 @@ public TransientVector pop(){
}
if(shift > 5 && newroot.array[1] == null)
{
- newroot = (Node) newroot.array[0];
+ newroot = ensureEditable((Node) newroot.array[0]);
newshift -= 5;
}
root = newroot;
View
6 test/clojure/test_clojure/transients.clj
@@ -3,8 +3,10 @@
(deftest popping-off
(testing "across a node boundary"
- (let [v (-> (range 33) vec)]
- (is (= (subvec v 0 31) (-> v transient pop! pop! persistent!)))))
+ (are [n]
+ (let [v (-> (range n) vec)]
+ (= (subvec v 0 (- n 2)) (-> v transient pop! pop! persistent!)))
+ 33 (+ 32 (inc (* 32 32))) (+ 32 (inc (* 32 32 32)))))
(testing "off the end"
(is (thrown-with-msg? IllegalStateException #"Can't pop empty vector"
(-> [] transient pop!)))))

0 comments on commit 59ecee6

Please sign in to comment.
Something went wrong with that request. Please try again.