Repository navigation
cat: resize the output pipe once per invocation #15506
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -410,6 +410,12 @@ fn cat_files<'a, I>(files: I, options: &OutputOptions) -> UResult<()> | |
| where | ||
| I: IntoIterator<Item = &'a OsString>, | ||
| { | ||
| #[cfg(any(target_os = "linux", target_os = "android"))] | ||
| if options.can_print_fast() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the description mentions a regression test for mixed file/stdin order but i don't see it in the commit, please add it in tests/by-util/test_cat.rs
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this PR needs a test since it is performance-related PR.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we test something, it should count pipe2 call by |
||
| // All operands share stdout. Try to resize it once. | ||
| let _ = | ||
| rustix::pipe::fcntl_setpipe_size(io::stdout(), uucore::pipes::MAX_ROOTLESS_PIPE_SIZE); | ||
| } | ||
| let mut state = OutputState { | ||
| line_number: LineNumber::new(), | ||
| at_line_start: true, | ||
|
|
@@ -496,7 +502,7 @@ fn print_fast<R: FdReadable>(handle: &mut InputHandle<R>) -> CatResult<()> { | |
| let mut stdout = stdout; | ||
| // Try to use the splice() system call for faster writing. If it works, we're done. | ||
| #[cfg(any(target_os = "linux", target_os = "android"))] | ||
| if uucore::pipes::splice_unbounded_auto(&handle.reader, &mut stdout)?.is_ok() { | ||
| if uucore::pipes::splice_unbounded_broker(&handle.reader, &mut stdout)?.is_ok() { | ||
| return Ok(()); | ||
| } | ||
|
|
||
|
|
||
This comment was marked as low quality.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as low quality.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.