Repository navigation
od: print -S offsets through InputOffset - #15648
Merged
sylvestre merged 1 commit intoOct 24, 2026
Merged
Conversation
Follow-up to uutils#15625: the strings mode had its own copy of the offset formats. InputOffset now implements Display, format_byte_offset uses it, and -S writes the offset through it without an extra allocation.
|
Binary size comparison: |
Contributor
|
Thanks for your PR |
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.
Follow-up to #15625, as suggested in #15625 (comment).
extract_strings_from_inputhad its own copy of the offset formats, which is how the-S -Axwidth drifted from the normal dump. It now prints the offset throughInputOffset, so both use the same formats.InputOffsetimplementsDisplaywith the formats thatformat_byte_offsetused.format_byte_offsetnow returnsself.to_string(), so its callers and unit tests are unchanged.-Swrites the offset withwriteln!(writer, "{offset} {string_content}"). With-Anit still prints only the string. I first usedformat_byte_offset()there, but theStringit allocates for each string madeod -S4about 2% slower on a 400k-string file. WithDisplaythere is no extra allocation, and the time is the same as onmain.There is no change in output. All
test_odtests and theuu_odunit tests pass.od -Swith-Ad,-Ax,-Ao,-An,-jand-N, plus a few normal dumps, give the same output as GNU 9.12.cargo bench -p uu_odand timings ofod -S4,od -Ax -S4andod -Ax -tx1with a release build show no change against the merge base beyond run-to-run noise.I used an AI assistant to help draft parts of the code; I reviewed the changes and ran the tests myself.