Skip to content

Commit

Permalink
Bugfix: Diff calculation was detecting updates where there were not any.
Browse files Browse the repository at this point in the history
Diff calculation did not check if values changed when a key is in
both maps that are being diffed. This means that it was detecting an
update, while in fact the value had not changed.
  • Loading branch information
jorisdral authored and jasagredo committed Dec 2, 2022
1 parent f2af285 commit 1615378
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions anti-diff/src/Data/Map/Diff/Strict.hs
Expand Up @@ -158,13 +158,16 @@ nonEmptyDiffHistory (DiffHistory sq) = NEDiffHistory <$> NESeq.nonEmptySeq sq
------------------------------------------------------------------------------}

-- | Compute the difference between @'Values'@.
diff :: Ord k => Values k v -> Values k v -> Diff k v
diff :: (Ord k, Eq v) => Values k v -> Values k v -> Diff k v
diff (Values m1) (Values m2) = Diff $
Merge.merge
(Merge.mapMissing $ \_k v -> singletonDelete v)
(Merge.mapMissing $ \_k v -> singletonInsert v)
(Merge.zipWithMaybeMatched $ \ _k v1 v2 ->
Just $ singletonDelete v1 `unsafeMappend` singletonInsert v2
if v1 == v2 then
Nothing
else
Just $ singletonDelete v1 `unsafeMappend` singletonInsert v2
)
m1
m2
Expand Down
Expand Up @@ -676,7 +676,7 @@ applyLedgerTablesDiffsTicked = flip (zipOverLedgerTablesTicked $ flip rawApplyDi
-- Calculate differences

rawCalculateDifference ::
Ord k
(Ord k, Eq v)
=> ValuesMK k v
-> ValuesMK k v
-> TrackingMK k v
Expand Down

0 comments on commit 1615378

Please sign in to comment.