From bedf143ce587c823c7f168a869d16cce4153e46b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 12 Feb 2014 22:36:16 -0400 Subject: improve simplifier --- Logs/MetaData.hs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'Logs') diff --git a/Logs/MetaData.hs b/Logs/MetaData.hs index 153d8fa63..6d070125c 100644 --- a/Logs/MetaData.hs +++ b/Logs/MetaData.hs @@ -96,14 +96,16 @@ addMetaData k metadata = do - from the remote became available, it would be older than the simplified - line, and its change to bar would not take effect. That is wrong. - - - Instead, simplify it to: (this simpliciation is optional) + - Instead, simplify it to: - - - 100 bar +y (100 foo +x bar +y) + - 100 bar +y - 200 foo -x - + - TODO: The above simplification is not implemented yet. + - - Now merging with the remote yields: - - - 100 bar +y (100 foo +x bar +y) + - 100 bar +y - 150 bar +z baz +w - 200 foo -x - @@ -111,15 +113,6 @@ addMetaData k metadata = do - - 150 bar +z baz +w - 200 foo -x - - - - In practice, there is little benefit to making simplications to lines - - that only remove some values, while leaving others on the line. - - Since lines are kept in git, that likely increases the size of the - - git repo (depending on compression), rather than saving any space. - - - - So, the only simplication that is actually done is to throw out an - - old line when all the values in it have been overridden by lines that - - came after. -} simplifyLog :: Log MetaData -> Log MetaData simplifyLog s = case S.toDescList s of @@ -128,8 +121,9 @@ simplifyLog s = case S.toDescList s of where go c _ [] = c go c newer (l:ls) - | hasUniqueMetaData newer older = - go (l:c) (unionMetaData older newer) ls - | otherwise = go c newer ls + | unique == newMetaData = go c newer ls + | otherwise = go (l { value = unique } : c) + (unionMetaData unique newer) ls where older = value l + unique = older `differenceMetaData` newer -- cgit v1.2.3