-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use MutableByteArray as the primitive for the ring buffer #2761
Conversation
facacc5
to
09ea70b
Compare
I need to add some more sanity tests before merging this. |
3d2b44f
to
ad8ebce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the changelog, packdiff reports some constraint changes.
@@ -1676,7 +1675,7 @@ takeEndBySeq patArr (Fold fstep finitial fextract ffinal) = | |||
res <- fstep s x | |||
case res of | |||
Partial s1 -> do | |||
old <- liftIO $ peek rh | |||
(old :: a) <- liftIO $ PEEK_ELEM(a, rh, (Ring.ringContents rb)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this passing hlint? it has redundant brackets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any redundant brackets.
Are the brackets here (old :: a)
redundant?
If so, need to check hlint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe because PEEK_ELEM is a macro, my hls was showing a redundant bracket around ringContents rb
.
@@ -137,7 +147,7 @@ advance rb ringHead = | |||
-- array. | |||
{-# INLINE moveBy #-} | |||
moveBy :: Int -> Ring a -> Int -> Int | |||
moveBy by rb ringHead = (ringHead + by) `mod` ringCapacity rb | |||
moveBy by rb ringHead = (ringHead + by) `mod1` ringCapacity rb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usually we should not be moving it by more than the ring size. But we have to handle the case if someone does that. Anyway, it seems this function is not used anywhere.
e8785bc
to
33ac369
Compare
33ac369
to
69c8129
Compare
This is a subtle bug. The old code was doing PTR_NEXT(rh) rather than using rh1 and that was for a good reason I guess. If we are at the last element of the ring, rh1 would become 0 and we would not fold anything.
69c8129
to
f5f880a
Compare
This looks suspiciously good.
This PR supersedes: