-
Notifications
You must be signed in to change notification settings - Fork 116
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
[runtime] Improve Split Functionality in DemiBuffer
#546
Conversation
DemiBuffer
cc83c47
to
2058821
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.
Looks good to me other than the duplicated code.
/// - The target [DemiBuffer] must be a single buffer segment (not a chain). | ||
/// - The target [DemiBuffer] should be large enough to hold `offset`. | ||
/// | ||
pub fn split_front(&mut self, offset: usize) -> Result<Self, Fail> { |
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.
To eliminate duplicate code, we should probably have a shared function here that gives both halves back and then split_front and split_back just return the front_half or back_half.
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.
Sure... I merged the two functions in one, called split()
2058821
to
66889f8
Compare
This commit partially addresses #542 - Renamed DemiBuffer::split_off() to DemiBuffer::split_back().
Improved API documentation for DemiBuffer::split_back().
This commit introduces minor enhancements in DemiBuffer::split_back(): - Introduced DemiBuffer::is_multi_segment() helper function. - Simplified logic for sanity checking split_back() operation. - Improved comments on the split_back() function.
Improved unit test for DemiBuffer::split_back().
This commit partially addresses #542 - Introduced the DemiBuffer::split_front() operation. - Introduced a unit test for DemiBuffer::split_front().
66889f8
to
31edf07
Compare
Description
This PR closes #542
Summary of Changes
DemiBuffer::split_off()
toDemiBuffer::split_back()
DemiBuffer::split_back()
DemiBuffer::split_front()
DemiBuffer::split_front()