Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix pop! when the tree depth decreases

Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
  • Loading branch information...
commit 59ecee6a6f037612b3b1ed2d939f5e0017f2dd11 1 parent 2ac9319
@cgrand cgrand authored stuarthalloway committed
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!)))))
Please sign in to comment.
Something went wrong with that request. Please try again.