Repository navigation
Commit 74e3a69
authored
ext/standard: Optimize str_pad() using doubling copies (#23661)
This PR optimizes the user-visible `str_pad()` by reducing repeated small
copy operations during padding. In `php_str_pad_fill()`, the algorithm now uses
doubling copies to grow the written region exponentially. This lowers memcpy counts
and improves throughput for large repeated-pattern padding workloads.
Added `str_pad_repeated_pattern.phpt` to validate repeated pattern and partial-tail
boundaries, including multi-byte patterns and all pad directions. Behavior is
unchanged; this is a performance-only change and is now recorded in the PHP 8.6
performance changelog.1 parent daf0765 commit 74e3a69
2 files changed
Lines changed: 8 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1105 | 1105 | | |
1106 | 1106 | | |
1107 | 1107 | | |
| 1108 | + | |
1108 | 1109 | | |
1109 | 1110 | | |
1110 | 1111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5891 | 5891 | | |
5892 | 5892 | | |
5893 | 5893 | | |
| 5894 | + | |
5894 | 5895 | | |
5895 | | - | |
5896 | | - | |
5897 | | - | |
| 5896 | + | |
| 5897 | + | |
5898 | 5898 | | |
5899 | | - | |
5900 | | - | |
| 5899 | + | |
| 5900 | + | |
| 5901 | + | |
| 5902 | + | |
5901 | 5903 | | |
5902 | 5904 | | |
5903 | 5905 | | |
| |||
0 commit comments