Skip to content

Commit 9e0d973

Browse files
toyboot4eerikd
authored andcommitted
Add INLINE to nub functions
`nubMutBy` is marked as `INLINABLE`, but change it if `INLINE` is faster
1 parent b9b1518 commit 9e0d973

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Data/Vector/Algorithms.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import qualified Data.Vector.Algorithms.Search as S
1818
-- | The `nub` function which removes duplicate elements from a vector.
1919
nub :: forall v e . (V.Vector v e, Ord e) => v e -> v e
2020
nub = nubBy compare
21+
{-# INLINE nub #-}
2122

2223
-- | A version of `nub` with a custom comparison predicate.
2324
--
@@ -31,6 +32,7 @@ nubBy cmp vec = runST $ do
3132
destMV <- nubByMut sortUniqBy cmp mv
3233
v <- V.unsafeFreeze destMV
3334
pure (V.force v)
35+
{-# INLINE nubBy #-}
3436

3537
-- | The `nubByMut` function takes in an in-place sort algorithm
3638
-- and uses it to do a de-deduplicated sort. It then uses this to
@@ -72,3 +74,4 @@ nubByMut alg cmp inp = do
7274
go (srcInd + 1) (destInd + 1)
7375
go 0 0
7476
pure dest
77+
{-# INLINABLE nubByMut #-}

0 commit comments

Comments
 (0)