summaryrefslogtreecommitdiff
path: root/Logs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-01-31 18:40:42 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-01-31 19:06:22 -0400
commit7fd21be7f967bdc21530b730f595379b23fe1174 (patch)
treed2af9101541d8166b2035271967bb3ac01751e36 /Logs
parent164466c987a7607a5f598b36e5b3111a68bd101f (diff)
Some optimisations to string splitting code.
Turns out that Data.List.Utils.split is slow and makes a lot of allocations. Here's a much simpler single character splitter that behaves the same (even in wacky corner cases) while running in half the time and 75% the allocations. As well as being an optimisation, this helps move toward eliminating use of missingh. (Data.List.Split.splitOn is nearly as slow as Data.List.Utils.split and allocates even more.) I have not benchmarked the effect on git-annex, but would not be surprised to see some parsing of eg, large streams from git commands run twice as fast, and possibly in less memory. This commit was sponsored by Boyd Stephen Smith Jr. on Patreon.
Diffstat (limited to 'Logs')
-rw-r--r--Logs/Transfer.hs2
-rw-r--r--Logs/UUID.hs2
2 files changed, 2 insertions, 2 deletions
diff --git a/Logs/Transfer.hs b/Logs/Transfer.hs
index 28f7b0a26..903db96fe 100644
--- a/Logs/Transfer.hs
+++ b/Logs/Transfer.hs
@@ -268,7 +268,7 @@ readTransferInfo mpid s = TransferInfo
filename
| end rest == "\n" = beginning rest
| otherwise = rest
- bits = split " " firstline
+ bits = splitc ' ' firstline
numbits = length bits
time = if numbits > 0
then Just <$> parsePOSIXTime =<< headMaybe bits
diff --git a/Logs/UUID.hs b/Logs/UUID.hs
index 60c8a2ef9..4c84d10bd 100644
--- a/Logs/UUID.hs
+++ b/Logs/UUID.hs
@@ -66,7 +66,7 @@ fixBadUUID = M.fromList . map fixup . M.toList
newertime (LogEntry (Date d) _) = d + minimumPOSIXTimeSlice
newertime (LogEntry Unknown _) = minimumPOSIXTimeSlice
minimumPOSIXTimeSlice = 0.000001
- isuuid s = length s == 36 && length (split "-" s) == 5
+ isuuid s = length s == 36 && length (splitc '-' s) == 5
{- Records the uuid in the log, if it's not already there. -}
recordUUID :: UUID -> Annex ()