Skip to content

Conversation

@blyxxyz
Copy link
Contributor

@blyxxyz blyxxyz commented Nov 19, 2025

This PR removes most of the unnecessary lossy OS string conversions (Path::display(), .to_string_lossy()). There are many more left but this gets the low-hanging fruit.

Most of these conversions happened for formatted messages. This is unnecessary because .quote()/.maybe_quote() can already handle OS strings. Sometimes those methods weren't used yet even though they should be so I added them (and removed manual quotation from the translations).

I also applied OsWrite/println_verbatim in a few places where we need to write unformatted OS strings to stdout. See c804e51.

This comes up a lot for quoted strings in messages: OS strings can be
quoted directly and this prevents information loss.

This commit removes ~60% of the calls to these methods (modulo
tests). Some of the remaining calls are benign, for example because
they convert solely to check for the presence of ASCII
characters. Others are nontrivial to improve.
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 19, 2025

CodSpeed Performance Report

Merging #9337 will degrade performances by 4.85%

Comparing blyxxyz:lossy-string-cleanup (301165a) with main (909553a)

Summary

⚡ 1 improvement
❌ 3 regressions
✅ 122 untouched
⏩ 6 skipped1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
mv_force_overwrite 125.2 ms 131.6 ms -4.85%
sort_ascii_c_locale 22.5 ms 21.5 ms +4.64%
sort_reverse_mixed 38.1 ms 39.1 ms -2.51%
tsort_input_parsing_heavy[5000] 81.7 ms 84.6 ms -3.37%

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/chmod/no-x. tests/chmod/no-x is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/ls/infloop. tests/ls/infloop is passing on 'main'. Maybe you have to rebase?

@sylvestre
Copy link
Contributor

Seems that some are not. Unnecessary

Part of the error message was left out due to a misreading of
tests/chmod/no-x's output. It filters out this part for the sake of
normalization between different tools.
@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@blyxxyz
Copy link
Contributor Author

blyxxyz commented Nov 21, 2025

Should be good now. The problem was error message formatting, not the sanitization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants