-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Remove slice deque #30
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Correctness requires that this method definitely fills the buffer with at least
MIN_BUFFER_SIZE
bytes, or all bytes until the end of the file. Is this true with the new implementation?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.
It loops until available_data in the buffer is MIN_BUFFER_SIZE and it only breaks out of the loop when it reads no more data, which is the same logic as was used with slice-deque, so yes that behaviour is unchanged.
To be honest when changing that function I was unsure why it needed to read to fill the buffer that far. It can't be for correctness in parsing as far as I understand it there is no reason to see that far ahead. And it's unnecessary for safety reasons (the buffer gets fully initialized at the very beginning and constantly reused, so there are never any poisonous undefined bytes that can get read).
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.
It needs this only in a one or two places, parsing headers and comments, so that the entire header/comment will be present in the slice at once. All other places could use a more relaxed "peek", if there's a performance difference.
Is it not possible for
space()
to be empty, and thenread()
being called on a 0-sized buffer and breaking out of the loop?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.
Unless the consume_noshift variant of consume is used the buffer will be shifted when the position pointer of the buffer is over the halfway point in it's internal storage.
That means that available_data() + available_space() should always be more than half of the buffer size which I kept at MIN_BUFFER_SIZE * 2.
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.
Ah, cool.