-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Implement Seek::stream_position() for BufReader #74366
Conversation
r? @kennytm (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
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.
Looks mostly good to me! Only thing I noticed is that the subtraction might underflow if the inner reader has a buggy stream_position
implementation. Not sure if we really need to harden against that. But I think I would prefer, for now, if you could replace the subtraction with:
pos.checked_sub(...).expect("buggy `stream_position` implementation in inner reader of BufReader")
Or something like that.
Updated the implementation to check for subtraction underflow / overflow. Realized that besides a buggy inner reader, this situation can also occur when misusing the (unfortunately public) |
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.
Sorry for the delay. But looks almost ready to merge now! Just a tiny thing I noticed.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Oops, I found another minor thing °_°
Sorry for not noticing that in my last review.
Looks good to me! @bors r+ Thanks for sticking with this PR for so long! :) |
📌 Commit 246d327 has been approved by |
☀️ Test successful - checks-actions, checks-azure |
Optimization over
BufReader::seek()
for getting the current position without flushing the internal buffer.Related to #31100. Based on the code in #70577.