summaryrefslogtreecommitdiff
path: root/Utility/Quvi.hs
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 /Utility/Quvi.hs
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 'Utility/Quvi.hs')
-rw-r--r--Utility/Quvi.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/Utility/Quvi.hs b/Utility/Quvi.hs
index d33d79bb8..ff1ad854c 100644
--- a/Utility/Quvi.hs
+++ b/Utility/Quvi.hs
@@ -124,14 +124,14 @@ supported Quvi09 url = (firstlevel <&&> secondlevel)
Nothing -> return False
Just auth -> do
let domain = map toLower $ uriRegName auth
- let basedomain = intercalate "." $ reverse $ take 2 $ reverse $ split "." domain
+ let basedomain = intercalate "." $ reverse $ take 2 $ reverse $ splitc '.' domain
any (\h -> domain `isSuffixOf` h || basedomain `isSuffixOf` h)
. map (map toLower) <$> listdomains Quvi09
secondlevel = snd <$> processTranscript "quvi"
(toCommand [Param "dump", Param "-o", Param url]) Nothing
listdomains :: QuviVersion -> IO [String]
-listdomains Quvi09 = concatMap (split ",")
+listdomains Quvi09 = concatMap (splitc ',')
. concatMap (drop 1 . words)
. filter ("domains: " `isPrefixOf`) . lines
<$> readQuvi (toCommand [Param "info", Param "-p", Param "domains"])