summaryrefslogtreecommitdiff
path: root/Remote
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 /Remote
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 'Remote')
-rw-r--r--Remote/BitTorrent.hs2
-rw-r--r--Remote/Bup.hs2
-rw-r--r--Remote/Helper/Encryptable.hs2
3 files changed, 3 insertions, 3 deletions
diff --git a/Remote/BitTorrent.hs b/Remote/BitTorrent.hs
index 0ec78aa64..2f29f5baa 100644
--- a/Remote/BitTorrent.hs
+++ b/Remote/BitTorrent.hs
@@ -302,7 +302,7 @@ ariaProgress (Just sz) meter ps = do
=<< ariaParams ps
parseAriaProgress :: Integer -> ProgressParser
-parseAriaProgress totalsize = go [] . reverse . split ['\r']
+parseAriaProgress totalsize = go [] . reverse . splitc '\r'
where
go remainder [] = (Nothing, remainder)
go remainder (x:xs) = case readish (findpercent x) of
diff --git a/Remote/Bup.hs b/Remote/Bup.hs
index 332e8d5dc..75b379558 100644
--- a/Remote/Bup.hs
+++ b/Remote/Bup.hs
@@ -254,7 +254,7 @@ bup2GitRemote r
else giveup "please specify an absolute path"
| otherwise = Git.Construct.fromUrl $ "ssh://" ++ host ++ slash dir
where
- bits = split ":" r
+ bits = splitc ':' r
host = Prelude.head bits
dir = intercalate ":" $ drop 1 bits
-- "host:~user/dir" is not supported specially by bup;
diff --git a/Remote/Helper/Encryptable.hs b/Remote/Helper/Encryptable.hs
index 45ceae068..029ac4b09 100644
--- a/Remote/Helper/Encryptable.hs
+++ b/Remote/Helper/Encryptable.hs
@@ -165,7 +165,7 @@ extractCipher c = case (M.lookup "cipher" c,
Just $ SharedCipher (fromB64bs t)
_ -> Nothing
where
- readkeys = KeyIds . split ","
+ readkeys = KeyIds . splitc ','
describeEncryption :: RemoteConfig -> String
describeEncryption c = case extractCipher c of