Optimize the single array case for spliceArrays

This commit is contained in:
Harendra Kumar 2019-06-11 15:28:46 +05:30
parent 6accd3f2fd
commit 6e476f424b

View File

@ -513,7 +513,16 @@ spliceArraysBuffered s = do
-- @since 0.7.0
{-# INLINE spliceArrays #-}
spliceArrays :: (MonadIO m, Storable a) => SerialT m (Array a) -> m (Array a)
spliceArrays = spliceArraysBuffered
spliceArrays s = do
r <- S.uncons s
case r of
Nothing -> write S.nil
Just (h, t) -> do
r1 <- S.uncons t
case r1 of
Nothing -> return h
Just (h1, t1) -> spliceArraysBuffered $
h `S.cons` h1 `S.cons` t1
-- spliceArrays = _spliceArraysRealloced
-- | Create an 'Array' from a stream. This is useful when we want to create a