This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit cb2f04e
authored
Unrolled build for rust-lang#136662
Rollup merge of rust-lang#136662 - thaliaarchi:formatter-pad-char-count, r=m-ou-se
Count char width at most once in `Formatter::pad`
When both width and precision flags are specified, then `Formatter::pad` counts the character width twice. Instead, record the character width when truncating it to the precision, so it does not need to be recomputed. Simplify control flow so the cases are more clear.
Related:
- 6c9e708 (`fmt::Formatter::pad`: don't call chars().count() more than one time, 2021-09-01): Reduce counting chars from thrice to twice in worst case
- ede39ae (feat: reinterpret `precision` field for strings, 2016-06-29): Change meaning of precision for strings
- b820748 (Implement formatting arguments for strings and integers, 2013-08-10): Implement `Formatter::pad`1 file changed
+29
-37
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1693 | 1693 | | |
1694 | 1694 | | |
1695 | 1695 | | |
1696 | | - | |
| 1696 | + | |
1697 | 1697 | | |
1698 | 1698 | | |
1699 | 1699 | | |
1700 | | - | |
| 1700 | + | |
| 1701 | + | |
1701 | 1702 | | |
1702 | | - | |
1703 | | - | |
1704 | | - | |
1705 | | - | |
1706 | | - | |
1707 | | - | |
1708 | | - | |
1709 | | - | |
1710 | | - | |
1711 | | - | |
1712 | | - | |
1713 | | - | |
1714 | | - | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
1715 | 1713 | | |
1716 | | - | |
| 1714 | + | |
| 1715 | + | |
1717 | 1716 | | |
1718 | | - | |
1719 | | - | |
1720 | | - | |
1721 | | - | |
1722 | | - | |
1723 | | - | |
1724 | | - | |
1725 | | - | |
1726 | | - | |
1727 | | - | |
1728 | | - | |
1729 | | - | |
1730 | | - | |
1731 | | - | |
1732 | | - | |
1733 | | - | |
1734 | | - | |
1735 | | - | |
1736 | | - | |
1737 | | - | |
1738 | | - | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
1739 | 1731 | | |
1740 | 1732 | | |
1741 | 1733 | | |
| |||
0 commit comments