summaryrefslogtreecommitdiff
path: root/Logs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-12 23:24:04 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-12 23:24:04 -0400
commit09edd77928dd55f36292c0e299e6ace70da84578 (patch)
tree6fd9d2ba43f180706e3c8f70342c9ef233e39137 /Logs
parent0fb05a9d7585206472c0bc3ae7fe4bf38b069f1b (diff)
avoid churning in git to no benefit when optimising metadata log
I think this is now optimal.
Diffstat (limited to 'Logs')
-rw-r--r--Logs/MetaData.hs19
1 files changed, 14 insertions, 5 deletions
diff --git a/Logs/MetaData.hs b/Logs/MetaData.hs
index 6d070125c..0310ccc17 100644
--- a/Logs/MetaData.hs
+++ b/Logs/MetaData.hs
@@ -90,7 +90,7 @@ addMetaData k metadata = do
-
- An unmerged remote has:
-
- - 150 bar +z baz +w
+ - 150 bar -y baz +w
-
- If what we have were simplified to "200 foo -x bar +y" then when the line
- from the remote became available, it would be older than the simplified
@@ -101,12 +101,15 @@ addMetaData k metadata = do
- 100 bar +y
- 200 foo -x
-
- - TODO: The above simplification is not implemented yet.
+ - (Note that this ends up with the same number of lines as the
+ - unsimplified version, so there's really no point in updating
+ - the log to this version. Doing so would only add data to git,
+ - with little benefit.)
-
- Now merging with the remote yields:
-
- 100 bar +y
- - 150 bar +z baz +w
+ - 150 bar -y baz +w
- 200 foo -x
-
- Simplifying again:
@@ -115,10 +118,16 @@ addMetaData k metadata = do
- 200 foo -x
-}
simplifyLog :: Log MetaData -> Log MetaData
-simplifyLog s = case S.toDescList s of
- (newest:rest) -> S.fromList $ go [newest] (value newest) rest
+simplifyLog s = case sl of
+ (newest:rest) ->
+ let sl' = go [newest] (value newest) rest
+ in if length sl' < length sl
+ then S.fromList sl'
+ else s
_ -> s
where
+ sl = S.toDescList s
+
go c _ [] = c
go c newer (l:ls)
| unique == newMetaData = go c newer ls