[commit: packages/containers] ghc-head: Optimize Map.foldMapWithKey. (e60634d)
git at git.haskell.org
git at git.haskell.org
Wed Sep 4 21:24:46 CEST 2013
Repository : ssh://git@git.haskell.org/containers
On branch : ghc-head
Link : http://git.haskell.org/?p=packages/containers.git;a=commit;h=e60634d138fe1170899678f4e5d7bf42c388fae8
>---------------------------------------------------------------
commit e60634d138fe1170899678f4e5d7bf42c388fae8
Author: Milan Straka <fox at ucw.cz>
Date: Tue Jul 2 21:25:31 2013 +0200
Optimize Map.foldMapWithKey.
Use optimalizations from foldMap and traverseWithKey -- associativity
and test for leaves.
>---------------------------------------------------------------
e60634d138fe1170899678f4e5d7bf42c388fae8
Data/Map/Base.hs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Data/Map/Base.hs b/Data/Map/Base.hs
index 4a1600d..fa2fa6a 100644
--- a/Data/Map/Base.hs
+++ b/Data/Map/Base.hs
@@ -1884,7 +1884,8 @@ foldMapWithKey :: Monoid m => (k -> a -> m) -> Map k a -> m
foldMapWithKey f = go
where
go Tip = mempty
- go (Bin _ k v l r) = go l `mappend` f k v `mappend` go r
+ go (Bin 1 k v _ _) = f k v
+ go (Bin _ k v l r) = go l `mappend` (f k v `mappend` go r)
{-# INLINE foldMapWithKey #-}
{--------------------------------------------------------------------
More information about the ghc-commits
mailing list