-
Notifications
You must be signed in to change notification settings - Fork 748
Enable equality/inequality constraints against non-seekable steams #4483
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
Conversation
For the inequality tests, I made the expected and actual streams of the same size. I can double-up each inequality test where the stream lengths aren't equal, let me know if it's worth it. Same with streams whose contents exceed the |
if (xStream.Length != yStream.Length) return false; | ||
bool bothSeekable = xStream.CanSeek && yStream.CanSeek; | ||
|
||
if (bothSeekable && xStream.Length != yStream.Length) return false; |
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.
Thanks, this is a nice early bailout optimization
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.
Thanks @RenderMichael this looks great! I've pulled the changes and they work great. I also can't seem to find any edge cases you haven't already accounted for :)
Fixes #4476
Instead of using the stream's length as a stopping condition, we check that the amount of bytes read in the previous read operation is greater than 0.