@@ -111,11 +111,8 @@ packArraysChunksOf n (D.Stream step state) =
111111 then return $
112112 D.Skip (SpliceYielding buf (SpliceBuffering s arr))
113113 else do
114− buf' <- if MArray.byteCapacity buf < n
115− then liftIO $ MArray.realloc n buf
116− else return buf
117− buf'' <- MArray.splice buf' arr
118− return $ D.Skip (SpliceBuffering s buf'')
114+ buf1 <- MArray.splice buf arr
115+ return $ D.Skip (SpliceBuffering s buf1)
119116 D.Skip s -> return $ D.Skip (SpliceBuffering s buf)
120117 D.Stop -> return $ D.Skip (SpliceYielding buf SpliceFinish)
121118
@@ -158,22 +155,19 @@ lpackArraysChunksOf n (Fold step1 initial1 _ final1) =
158155
159156 step (Tuple' (Just buf) r1) arr = do
160157 let len = MArray.byteLength buf + MArray.byteLength arr
161− buf' <- if MArray.byteCapacity buf < len
162− then liftIO $ MArray.realloc (max n len) buf
163− else return buf
164− buf'' <- MArray.splice buf' arr
158+ buf1 <- MArray.splice buf arr
165159
166160 -- XXX this is common in both the equations of step
167161 if len >= n
168162 then do
169− r <- step1 r1 buf''
163+ r <- step1 r1 buf1
170164 case r of
171165 FL.Done _ -> return $ FL.Done ()
172166 FL.Partial s -> do
173167 _ <- final1 s
174168 res <- initial1
175169 return $ first (Tuple' Nothing) res
176− else return $ FL.Partial $ Tuple' (Just buf'') r1
170+ else return $ FL.Partial $ Tuple' (Just buf1) r1
177171
178172 -- XXX Several folds do extract >=> final, therefore, we need to make final
179173 -- return "m b" rather than using extract post it if we want extract to be
@@ -238,12 +232,8 @@ compactLEParserD n = ParserD.Parser step initial extract
238232 in if len > nBytes
239233 then return $ ParserD.Done 1 buf
240234 else do
241− buf1 <-
242− if MArray.byteCapacity buf < nBytes
243− then liftIO $ MArray.realloc nBytes buf
244− else return buf
245− buf2 <- MArray.splice buf1 arr
246− return $ ParserD.Partial 0 (Just buf2)
235+ buf1 <- MArray.splice buf arr
236+ return $ ParserD.Partial 0 (Just buf1)
247237
248238 extract Nothing = return $ ParserD.Done 0 MArray.nil
249239 extract (Just buf) = return $ ParserD.Done 0 buf
@@ -289,7 +279,7 @@ compactGEFold n = Fold step initial extract extract
289279 if MArray.byteCapacity buf < len
290280 then liftIO $ MArray.realloc (max len nBytes) buf
291281 else return buf
292− buf2 <- MArray.splice buf1 arr
282+ buf2 <- MArray.spliceUnsafe buf1 arr
293283 if len >= n
294284 then return $ FL.Done buf2
295285 else return $ FL.Partial (Just buf2)