paste: avoid unbounded buffering for single input#11060
Open
mattsu2020 wants to merge 4 commits intouutils:mainfrom
Open
paste: avoid unbounded buffering for single input#11060mattsu2020 wants to merge 4 commits intouutils:mainfrom
mattsu2020 wants to merge 4 commits intouutils:mainfrom
Conversation
- Refactored paste() to handle single input sources directly without buffering - Added paste_single_input_source() function for efficient streaming - Implemented InputSource::read() method for unified reading interface - Added tests for edge cases with /dev/zero and broken pipes - Improved performance by avoiding unnecessary line buffering for single inputs
|
GNU testsuite comparison: |
The test for handling broken pipes with /dev/zero was incorrectly expecting success. Updated to use `fails_silently()` to properly handle the expected failure when writing to a broken pipe.
Reordered the imports in paste.rs to group standard library imports together and maintain consistent ordering across the codebase. This improves code readability and follows the project's import organization conventions.
|
GNU testsuite comparison: |
xtqqczze
reviewed
Feb 23, 2026
src/uu/paste/src/paste.rs
Outdated
| Ok(()) | ||
| } | ||
|
|
||
| fn paste_single_input_source(mut input_source: InputSource, line_ending_byte: u8) -> UResult<()> { |
Contributor
There was a problem hiding this comment.
Suggested change
| fn paste_single_input_source(mut input_source: InputSource, line_ending_byte: u8) -> UResult<()> { | |
| fn write_single_input_source(writer: &mut impl Write, mut input_source: InputSource, line_ending_byte: u8) -> UResult<()> { |
then we can do let mut stdout = stdout().lock() once?
Contributor
Author
There was a problem hiding this comment.
That looks nicer.
Extracted the single input source handling logic from `paste_single_input_source` into a new `write_single_input_source` function that accepts a writer parameter. This allows the function to be more flexible and reusable, while also enabling the main `paste` function to maintain a single stdout lock for better performance. The change maintains the same functionality while improving code organization and performance.
|
GNU testsuite comparison: |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
pastefor non-serial single input by streaming bytes directly/dev/zerowrite failures (/dev/fulland broken pipe)Notes
Test
cargo test --test tests test_paste:: -- --nocapture