Skip to content

Commit

Permalink
fixes d/combine change map shrinking
Browse files Browse the repository at this point in the history
  • Loading branch information
xificurC committed Jul 8, 2024
1 parent 76a0e51 commit 43c5d2c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
12 changes: 5 additions & 7 deletions src/hyperfiddle/incseq/diff_impl.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,19 @@
(reduce disj! (transient fx)
(vals py)) py) fy)]
(if (< i d)
(let [j (p i i)
c (dissoc! c i)
f (disj! f i)]
(let [j (p i i)]
(if (< j size-before)
(recur (unchecked-inc i) d p c f)
(recur (unchecked-inc i) d p (dissoc! c i) (disj! f i))
(recur i (unchecked-dec d)
(p/compose (p/rotation i d)
p (p/rotation d j)) c f)))
(let [c (persistent! c)]
p (p/rotation d j)) (dissoc! c d) (disj! f d))))
(let [c (persistent! (dissoc! c d))]
{:degree d
:permutation (-> p (remove-shrunk-reorders size-after d) (remove-change-reorders (set (keys c))))
:grow (unchecked-subtract d size-before)
:shrink (unchecked-subtract d size-after)
:change c
:freeze (persistent! f)})))))
:freeze (persistent! (disj! f d))})))))
([x y & zs] (reduce combine (combine x y) zs)))

(defn subdiff [{:keys [grow shrink degree permutation change freeze]} size offset]
Expand Down
10 changes: 0 additions & 10 deletions test/hyperfiddle/incseq/diff_impl_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,4 @@
_ (diff-seq a), a->b (diff-seq b), b->c (diff-seq c)]
(= c (d/patch-vec a (d/combine a->b b->c))))))

(comment
(let [a [], b [0 1], c []
diff-seq (i/->seq-differ identity)
_ (diff-seq a), a->b (diff-seq b), b->c (diff-seq c), a->c (d/combine a->b b->c)]
(prn :a->b a->b)
(prn :b->c b->c)
(prn :combined a->c)
(= c (d/patch-vec a a->c)))
)

(tct/defspec d-combine-spec 100 d-combine)

0 comments on commit 43c5d2c

Please sign in to comment.