pr: write all characters in each row in a single loop #10475
+102
−93
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.
Depends on #10474
Write the contents of the entire row to a single String before writing the full row to stdout. Before this commit, each cell was put in its own String and then that String was written to stdout before moving on to the next cell in the row. After this commit, the contents of each cell in a row is appended to a single String, and that String is written to stdout only after all cells in the row have been processed.
This change will make it much easier to make improvements to the logic of which characters to write at each point in the row, since the current logic does not match the output GNU
prvery well. For example, the decision about whether to write a tab or multiple spaces requires knowing how many characters have been written in the current row, which was not easily accessible before.