diff --git a/vector/src/Data/Vector.hs b/vector/src/Data/Vector.hs index 9517d4fc..8ea3ca4d 100644 --- a/vector/src/Data/Vector.hs +++ b/vector/src/Data/Vector.hs @@ -305,10 +305,12 @@ instance Ord a => Ord (Vector a) where xs >= ys = Bundle.cmp (G.stream xs) (G.stream ys) /= LT instance Eq1 Vector where - liftEq eq xs ys = Bundle.eqBy eq (G.stream xs) (G.stream ys) + {-# INLINE liftEq #-} + liftEq = eqBy instance Ord1 Vector where - liftCompare cmp xs ys = Bundle.cmpBy cmp (G.stream xs) (G.stream ys) + {-# INLINE liftCompare #-} + liftCompare = cmpBy instance Semigroup (Vector a) where {-# INLINE (<>) #-} @@ -2166,6 +2168,7 @@ eqBy = G.eqBy -- -- @since 0.12.2.0 cmpBy :: (a -> b -> Ordering) -> Vector a -> Vector b -> Ordering +{-# INLINE cmpBy #-} cmpBy = G.cmpBy -- Conversions - Lists diff --git a/vector/src/Data/Vector/Generic.hs b/vector/src/Data/Vector/Generic.hs index c2114f7a..a8250b4d 100644 --- a/vector/src/Data/Vector/Generic.hs +++ b/vector/src/Data/Vector/Generic.hs @@ -757,6 +757,7 @@ concat vs = unstream (Bundle.flatten mk step (Exact n) (Bundle.fromList vs)) -- | /O(n)/ Concatenate all vectors in the non-empty list. concatNE :: Vector v a => NonEmpty.NonEmpty (v a) -> v a +{-# INLINE concatNE #-} concatNE = concat . NonEmpty.toList -- Monadic initialisation @@ -1135,6 +1136,7 @@ mapM f = unstreamM . Bundle.mapM f . stream -- index, yielding a vector of results. imapM :: (Monad m, Vector v a, Vector v b) => (Int -> a -> m b) -> v a -> m (v b) +{-# INLINE imapM #-} imapM f = unstreamM . Bundle.mapM (uncurry f) . Bundle.indexed . stream -- | /O(n)/ Apply the monadic action to all elements of a vector and ignore the @@ -2681,6 +2683,7 @@ cmp xs ys = compare (stream xs) (stream ys) -- -- > cmpBy compare == cmp cmpBy :: (Vector v a, Vector v b) => (a -> b -> Ordering) -> v a -> v b -> Ordering +{-# INLINE cmpBy #-} cmpBy c xs ys = Bundle.cmpBy c (stream xs) (stream ys) -- Show diff --git a/vector/src/Data/Vector/Mutable.hs b/vector/src/Data/Vector/Mutable.hs index 1c3496fb..b84f242c 100644 --- a/vector/src/Data/Vector/Mutable.hs +++ b/vector/src/Data/Vector/Mutable.hs @@ -71,6 +71,7 @@ module Data.Vector.Mutable ( ) where import Control.Monad (when, liftM) +import Control.Monad.ST (ST) import qualified Data.Vector.Generic.Mutable as G import Data.Vector.Internal.Check import Data.Primitive.Array @@ -171,14 +172,14 @@ instance G.MVector MVector a where basicClear v = G.set v uninitialised {-# INLINE moveBackwards #-} -moveBackwards :: PrimMonad m => MutableArray (PrimState m) a -> Int -> Int -> Int -> m () +moveBackwards :: MutableArray s a -> Int -> Int -> Int -> ST s () moveBackwards !arr !dstOff !srcOff !len = check Internal "not a backwards move" (dstOff < srcOff) $ loopM len $ \ i -> readArray arr (srcOff + i) >>= writeArray arr (dstOff + i) {-# INLINE moveForwardsSmallOverlap #-} -- Performs a move when dstOff > srcOff, optimized for when the overlap of the intervals is small. -moveForwardsSmallOverlap :: PrimMonad m => MutableArray (PrimState m) a -> Int -> Int -> Int -> m () +moveForwardsSmallOverlap :: MutableArray s a -> Int -> Int -> Int -> ST s () moveForwardsSmallOverlap !arr !dstOff !srcOff !len = check Internal "not a forward move" (dstOff > srcOff) $ do @@ -189,7 +190,7 @@ moveForwardsSmallOverlap !arr !dstOff !srcOff !len = where nonOverlap = dstOff - srcOff; overlap = len - nonOverlap -- Performs a move when dstOff > srcOff, optimized for when the overlap of the intervals is large. -moveForwardsLargeOverlap :: PrimMonad m => MutableArray (PrimState m) a -> Int -> Int -> Int -> m () +moveForwardsLargeOverlap :: MutableArray s a -> Int -> Int -> Int -> ST s () moveForwardsLargeOverlap !arr !dstOff !srcOff !len = check Internal "not a forward move" (dstOff > srcOff) $ do diff --git a/vector/src/Data/Vector/Primitive.hs b/vector/src/Data/Vector/Primitive.hs index 95d0d790..7e23ea61 100644 --- a/vector/src/Data/Vector/Primitive.hs +++ b/vector/src/Data/Vector/Primitive.hs @@ -1830,6 +1830,7 @@ eqBy = G.eqBy -- -- @since 0.12.2.0 cmpBy :: (Prim a, Prim b) => (a -> b -> Ordering) -> Vector a -> Vector b -> Ordering +{-# INLINE cmpBy #-} cmpBy = G.cmpBy -- Conversions - Lists diff --git a/vector/src/Data/Vector/Strict.hs b/vector/src/Data/Vector/Strict.hs index 01143b4b..c6c3eb3a 100644 --- a/vector/src/Data/Vector/Strict.hs +++ b/vector/src/Data/Vector/Strict.hs @@ -176,7 +176,6 @@ module Data.Vector.Strict ( import Data.Coerce import Data.Vector.Strict.Mutable ( MVector(..) ) import Data.Primitive.Array -import qualified Data.Vector.Fusion.Bundle as Bundle import qualified Data.Vector.Generic as G import qualified Data.Vector as V @@ -310,10 +309,12 @@ instance Ord a => Ord (Vector a) where (>=) = coerce ((>=) @(V.Vector a)) instance Eq1 Vector where - liftEq eq xs ys = Bundle.eqBy eq (G.stream xs) (G.stream ys) + {-# INLINE liftEq #-} + liftEq = eqBy instance Ord1 Vector where - liftCompare cmp xs ys = Bundle.cmpBy cmp (G.stream xs) (G.stream ys) + {-# INLINE liftCompare #-} + liftCompare = cmpBy instance Functor Vector where {-# INLINE fmap #-} @@ -2435,6 +2436,7 @@ eqBy = G.eqBy -- -- @since 0.13.2.0 cmpBy :: (a -> b -> Ordering) -> Vector a -> Vector b -> Ordering +{-# INLINE cmpBy #-} cmpBy = G.cmpBy -- Conversions - Lists diff --git a/vector/src/Data/Vector/Unboxed.hs b/vector/src/Data/Vector/Unboxed.hs index 4548cd8c..57ee1118 100644 --- a/vector/src/Data/Vector/Unboxed.hs +++ b/vector/src/Data/Vector/Unboxed.hs @@ -1289,6 +1289,7 @@ breakR = G.breakR -- -- @since 0.13.0.1 groupBy :: Unbox a => (a -> a -> Bool) -> Vector a -> [Vector a] +{-# INLINE groupBy #-} groupBy = G.groupBy -- | /O(n)/ Split a vector into a list of slices of the input vector. @@ -1308,6 +1309,7 @@ groupBy = G.groupBy -- -- @since 0.13.0.1 group :: (Unbox a, Eq a) => Vector a -> [Vector a] +{-# INLINE group #-} group = G.groupBy (==) -- Searching @@ -1965,6 +1967,7 @@ eqBy = G.eqBy -- -- @since 0.12.2.0 cmpBy :: (Unbox a, Unbox b) => (a -> b -> Ordering) -> Vector a -> Vector b -> Ordering +{-# INLINE cmpBy #-} cmpBy = G.cmpBy -- Conversions - Lists