[commit: containers] master: Inline Int{Map, Set}.{null, empty, singleton}. (c712fe4)
Paolo Capriotti
p.capriotti at gmail.com
Thu Jul 19 21:12:11 CEST 2012
Repository : ssh://darcs.haskell.org//srv/darcs/packages/containers
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/c712fe4d92c3bfae59323eb74ba2259cb3e45a77
>---------------------------------------------------------------
commit c712fe4d92c3bfae59323eb74ba2259cb3e45a77
Author: Milan Straka <fox at ucw.cz>
Date: Fri Apr 20 18:32:18 2012 +0200
Inline Int{Map,Set}.{null, empty, singleton}.
These are probably inlined anyway, but we explicitly INLINE
them in Map and Set, so we do also in IntMap and IntSet for consistency.
>---------------------------------------------------------------
Data/IntMap/Base.hs | 3 +++
Data/IntMap/Strict.hs | 1 +
Data/IntSet.hs | 3 +++
3 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/Data/IntMap/Base.hs b/Data/IntMap/Base.hs
index 850d62f..a77d7de 100644
--- a/Data/IntMap/Base.hs
+++ b/Data/IntMap/Base.hs
@@ -345,6 +345,7 @@ instance Data a => Data (IntMap a) where
null :: IntMap a -> Bool
null Nil = True
null _ = False
+{-# INLINE null #-}
-- | /O(n)/. Number of elements in the map.
--
@@ -437,6 +438,7 @@ findWithDefault def k = k `seq` go
empty :: IntMap a
empty
= Nil
+{-# INLINE empty #-}
-- | /O(1)/. A map of one element.
--
@@ -446,6 +448,7 @@ empty
singleton :: Key -> a -> IntMap a
singleton k x
= Tip k x
+{-# INLINE singleton #-}
{--------------------------------------------------------------------
Insert
diff --git a/Data/IntMap/Strict.hs b/Data/IntMap/Strict.hs
index 8c0c912..1ff087f 100644
--- a/Data/IntMap/Strict.hs
+++ b/Data/IntMap/Strict.hs
@@ -299,6 +299,7 @@ findWithDefault def k = def `seq` k `seq` go
singleton :: Key -> a -> IntMap a
singleton k x
= x `seq` Tip k x
+{-# INLINE singleton #-}
{--------------------------------------------------------------------
Insert
diff --git a/Data/IntSet.hs b/Data/IntSet.hs
index e449628..054cc11 100644
--- a/Data/IntSet.hs
+++ b/Data/IntSet.hs
@@ -293,6 +293,7 @@ instance Data IntSet where
null :: IntSet -> Bool
null Nil = True
null _ = False
+{-# INLINE null #-}
-- | /O(n)/. Cardinality of the set.
size :: IntSet -> Int
@@ -326,11 +327,13 @@ notMember k = not . member k
empty :: IntSet
empty
= Nil
+{-# INLINE empty #-}
-- | /O(1)/. A set of one element.
singleton :: Int -> IntSet
singleton x
= Tip (prefixOf x) (bitmapOf x)
+{-# INLINE singleton #-}
{--------------------------------------------------------------------
Insert
More information about the Cvs-libraries
mailing list