Commit 1f58504
committed
perf: skip builders for single-spec formats
Motivation:
Short format strings such as %08d or %20s have exactly one dynamic value and no static literal text, so the generic format path was allocating and appending through a StringBuilder only to return that single formatted value.
Modification:
Detect the single-spec/no-static-literal case in Format.format and return the computed formatted value directly after preserving all existing arity checks.
Result:
The repeat_format regression improves from 0.190 ms/op on upstream master to 0.133 ms/op locally, while large_string_template remains effectively neutral and the full Mill test matrix passes.
References:
Source idea: databricks#7761 parent 0ae7b78 commit 1f58504
1 file changed
Lines changed: 12 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
574 | 574 | | |
575 | 575 | | |
576 | 576 | | |
| 577 | + | |
577 | 578 | | |
578 | | - | |
579 | | - | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
580 | 584 | | |
581 | 585 | | |
582 | 586 | | |
| |||
731 | 735 | | |
732 | 736 | | |
733 | 737 | | |
734 | | - | |
735 | | - | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
736 | 743 | | |
737 | 744 | | |
738 | 745 | | |
| |||
741 | 748 | | |
742 | 749 | | |
743 | 750 | | |
744 | | - | |
| 751 | + | |
745 | 752 | | |
746 | 753 | | |
747 | 754 | | |
| |||
0 commit comments