Skip to content

perf(split): optimize FixedWidthNumber Display implementation#10723

Draft
CrazyRoka wants to merge 2 commits intouutils:mainfrom
CrazyRoka:optimize-split-number-format
Draft

perf(split): optimize FixedWidthNumber Display implementation#10723
CrazyRoka wants to merge 2 commits intouutils:mainfrom
CrazyRoka:optimize-split-number-format

Conversation

@CrazyRoka
Copy link
Contributor

Currently, the Display implementation for FixedWidthNumber collects all mapped digits into a temporary String before writing them to the formatter. This incurs an unnecessary heap allocation every time a number is formatted.

This change replaces formatting logic with direct write_char calls with optimization in mind.

@CrazyRoka
Copy link
Contributor Author

CrazyRoka commented Feb 5, 2026

There is 0.56% performance improvement. I see room for more optimizations here.
Apart from that, we might need more in depth benchmark, because existing one reports more than 50% wall time in locale initialization and clap building

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 6, 2026

Merging this PR will improve performance by 3.98%

⚡ 1 improved benchmark
✅ 283 untouched benchmarks
⏩ 38 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation cp_large_file[16] 381.3 µs 366.7 µs +3.98%

Comparing CrazyRoka:optimize-split-number-format (58c32e8) with main (da7ad84)

Open in CodSpeed

Footnotes

  1. 38 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.

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