File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -1090,7 +1090,7 @@ buildStepToCIOS (AllocationStrategy nextBuffer bufSize trim) =
1090
1090
-- Checking for empty case avoids allocating 'n-1' empty
1091
1091
-- buffers for 'n' insertChunkH right after each other.
1092
1092
if isEmpty
1093
- then fill nextStep buf
1093
+ then fill nextStep ( Buffer fpbuf ( BufferRange pbuf pe))
1094
1094
else do buf' <- nextBuffer (Just (buf, bufSize))
1095
1095
fill nextStep buf'
1096
1096
@@ -1101,8 +1101,9 @@ buildStepToCIOS (AllocationStrategy nextBuffer bufSize trim) =
1101
1101
| trim chunkSize size = do
1102
1102
bs <- S. createFp chunkSize $ \ fpbuf' ->
1103
1103
S. memcpyFp fpbuf' fpbuf chunkSize
1104
- -- FIXME: We could reuse the trimmed buffer here.
1105
- return $ Yield1 bs (mkCIOS False )
1104
+ -- Instead of allocating a new buffer after trimming,
1105
+ -- we re-use the old buffer and consider it empty.
1106
+ return $ Yield1 bs (mkCIOS True )
1106
1107
| otherwise =
1107
1108
return $ Yield1 (S. BS fpbuf chunkSize) (mkCIOS False )
1108
1109
where
You can’t perform that action at this time.
0 commit comments