on master help sign in
Reallocate only once in lpackArraysChunksOf
006fc5fHarendra Kumar
src/Streamly/Benchmark/FileIO/Array.hs+2−1
@@ -41,6 +41,7 @@ import qualified Streamly.Prelude as S
41import qualified Streamly.Internal as Internal
41import qualified Streamly.Internal as Internal
42
42
43#ifdef INSPECTION
43#ifdef INSPECTION
44+import Foreign.Storable (Storable)
44import Streamly.Streams.StreamD.Type (Step(..))
45import Streamly.Streams.StreamD.Type (Step(..))
45import Test.Inspection
46import Test.Inspection
46#endif
47#endif
@@ -128,6 +129,6 @@ linesUnlinesCopy inh outh =
128 $ FH.readArraysOf (1024*1024) inh
129 $ FH.readArraysOf (1024*1024) inh
129
130
130#ifdef INSPECTION
131#ifdef INSPECTION
131−-- inspect $ hasNoTypeClasses 'linesUnlinesCopy
132+inspect $ hasNoTypeClassesExcept 'linesUnlinesCopy [''Storable]
132-- inspect $ 'linesUnlinesCopy `hasNoType` ''Step
133-- inspect $ 'linesUnlinesCopy `hasNoType` ''Step
133#endif
134#endif
src/Streamly/Memory/Array/Types.hs+1−1
@@ -1087,7 +1087,7 @@ lpackArraysChunksOf n (Fold step1 initial1 extract1) =
1087 step (Tuple' (Just buf) r1) arr = do
1087 step (Tuple' (Just buf) r1) arr = do
1088 let len = byteLength buf + byteLength arr
1088 let len = byteLength buf + byteLength arr
1089 buf' <- if byteCapacity buf < len
1089 buf' <- if byteCapacity buf < len
1090− then liftIO $ realloc len buf
1090+ then liftIO $ realloc (max n len) buf
1091 else return buf
1091 else return buf
1092 buf'' <- spliceWith buf' arr
1092 buf'' <- spliceWith buf' arr
1093
1093