summaryrefslogtreecommitdiff
path: root/GitQueue.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-04-07 15:00:06 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-04-07 15:00:29 -0400
commit135d75f2b9c0f77b837da4243dea32a97d4088a5 (patch)
tree3c29b1593539e608f46638e20c56960b926f6bc0 /GitQueue.hs
parent4ea0b7c28850eb703562cd9dc84a02c49b5fda00 (diff)
avoid list traverse on queue
I wanted to use M.insertWith' (\_ l -> file:l) action [] m , but the order of the parameters and which to ignore is not clear, and seems unsafe to rely on.
Diffstat (limited to 'GitQueue.hs')
-rw-r--r--GitQueue.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/GitQueue.hs b/GitQueue.hs
index 480027fa0..be0fcfc4a 100644
--- a/GitQueue.hs
+++ b/GitQueue.hs
@@ -57,7 +57,11 @@ add :: Queue -> String -> [CommandParam] -> FilePath -> Queue
add (Queue n m) subcommand params file = Queue (n + 1) m'
where
action = Action subcommand params
- m' = M.insertWith' (++) action [file] m
+ -- There are probably few items in the map, but there
+ -- can be a lot of files per item. So, optimise adding
+ -- files.
+ m' = M.insertWith' const action files m
+ files = file:(M.findWithDefault [] action m)
{- Number of items in a queue. -}
size :: Queue -> Int