Repository navigation
Fix a few bugs in arrays - #1259
Conversation
cfd5ffa to
57ccaf6
Compare
57ccaf6 to
5a654f7
Compare
| return $ Array | ||
| { aStart = newPtr | ||
| , aEnd = pNew `plusPtr` size | ||
| , aEnd = pNew `plusPtr` (size - (size `mod` elemSize)) |
There was a problem hiding this comment.
since assert (size mod elemSize == 0) (return ()) is before so (size - (size mod elemSize)) must be == size.
There was a problem hiding this comment.
asserts are only for debug. In case this does not hold true we would still be fine in production.
| writeN :: MonadIO m => Int -> Fold m a (Array a) | ||
| writeN limit = Fold step initial extract | ||
| where | ||
| writeN len = Fold step initial extract |
There was a problem hiding this comment.
The previous implementation would not work for negative length. Anything else I'm missing?
There was a problem hiding this comment.
| i == limit = fmap FL.Done $ extract st
Discards the input x.
| if len > i1 | ||
| then return $ FL.Partial st | ||
| else fmap FL.Done $ extract st |
There was a problem hiding this comment.
Is it better to check if the length is negative in initial once instead of checking this on every step?
There was a problem hiding this comment.
Not sure what you mean by "length is negative". We are checking "len > i1" here which means we have to take more elements.
| -- XXX note that shirkToFit does not maintain alignment, in case we are | ||
| -- using aligned allocation. | ||
| extract = return -- liftIO . shrinkToFit | ||
| writeNAllocWith alloc n = FL.take n (writeNUnsafeWith alloc n) |
There was a problem hiding this comment.
yes, there is no diff.
| next marr i = do | ||
| let i1 = i + 1 | ||
| st = Tuple' marr i1 | ||
| if len > i1 | ||
| then return $ FL.Partial st | ||
| else fmap FL.Done $ extract st |
| next marr i = do | ||
| let i1 = i + 1 | ||
| st = Tuple' marr i1 | ||
| if len > i1 | ||
| then return $ FL.Partial st | ||
| else fmap FL.Done $ extract st |
|
Benchmarks master vs PR: |
9de24a7 to
acb8d3b
Compare
In toArrayMinChunk
fe23d8c to
98a6a00
Compare
No description provided.