Commits

Michał Marczyk committed 791ccd2

0.0.5: fix post-squash counts in splice-rrbts

Comments (0)

Files changed (3)

-(defproject flexvec "0.0.4"
+(defproject flexvec "0.0.5"
   :description "RRB-Trees for Clojure(Script) -- see Bagwell & Rompf"
   :url "https://github.com/michalmarczyk/flexvec"
   :license {:name "Eclipse Public License"

src/flexvec/rrbt.clj

           [n1 n2] (if (identical? n2 r2)
                     (squash-nodes nm s n1 ncnt1 n2 ncnt2)
                     (object-array (list n1 n2)))
-          ncnt1   (if (identical? n2 r2)
+          ncnt1   (if n2
                     (int ncnt1)
-                    (let [rngs (ranges nm n1)]
-                      (aget rngs (dec (aget rngs 32)))))
-          ncnt2   (int (cond
-                         (identical? n2 r2) (int ncnt2)
-                         (not n2) (int 0)
-                         :else (let [rngs (ranges nm n2)]
-                                 (aget rngs (dec (aget rngs 32))))))]
+                    (unchecked-add-int (int ncnt1) (int ncnt2)))
+          ncnt2   (if n2
+                    (int ncnt2)
+                    (int 0))]
       (if n2
         (let [arr      (object-array 33)
               new-root (.node nm nil arr)]

test/flexvec/core_test.clj

 (deftest test-splicing
   (testing "splicing"
     (is (dv/check-catvec 1025 1025 3245 1025 32768 1025 1025 10123 1025 1025))
+    (is (dv/check-catvec 10 40 40 40 40 40 40 40 40))
     (is (apply dv/check-catvec (repeat 30 33))))
   (testing "splicing (generative)"
     (is (try (dv/generative-check-catvec 250 30 10 60000)