Repository navigation
pr: indent the page header with -o like GNU - #16707
shivangithaker-0510 wants to merge 4 commits into
Conversation
| for x in header { | ||
| writer.write_all(&x)?; | ||
| for (index, x) in header.iter().enumerate() { | ||
| // Like GNU, the left margin goes on the first blank line and on the |
There was a problem hiding this comment.
| // Like GNU, the left margin goes on the first blank line and on the | |
| // The left margin goes on the first blank line and on the |
| for (index, x) in header.iter().enumerate() { | ||
| // The left margin goes on the first blank line and on the | ||
| // header text line, but not on the other blank header lines. | ||
| if index == 0 || index == 2 { |
There was a problem hiding this comment.
these 0 and 2 depend on the vec layout in header_content, could the margin be added there instead?
| vec![Vec::new(), Vec::new(), header_line, Vec::new(), Vec::new()] | ||
| // The left margin goes on the first blank line and on the header text | ||
| // line, but not on the other blank header lines. | ||
| let margin = vec![b' '; options.offset_spaces]; |
There was a problem hiding this comment.
this allocates the whole margin (twice) on every page, -o 999999999 without -t now needs ~2GB
could the margin still be streamed with write_offset_spaces, e.g. header_content only returns the text line and write_page lays out the 5 lines?
| .pipe_in("line\n") | ||
| .succeeds() | ||
| .stdout_only(format!("{header} line\n\x0c")); | ||
| } |
There was a problem hiding this comment.
please also run test_offset_large_value_does_not_abort_under_memory_limit without -t, so the header path is covered
|
GNU testsuite comparison: |
Merging this PR will improve performance by 14.88%1 warning, 1 note
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
With -o MARGIN, the margin was only written before body lines. Also write it before the first blank line of the header and before the header text line, like GNU pr does. Closes uutils#16211
2a90d33 to
1b192d3
Compare
With -o MARGIN, the margin was only written before body lines. Also write it before the first blank line of the header and before the header text line, like GNU pr does.
Closes #16211