[php-src] PR #14180: ext/bcmath: Avoid unnecessary `memset`
| From: | SakiTakamachi | Date: | Wed, 08 May 2024 15:33:08 +0000 |
| Subject: | [php-src] PR #14180: ext/bcmath: Avoid unnecessary `memset` | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-26084@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/14180
Author: SakiTakamachi
0 padding on the right is not required for calc. This is because when converting back to string,
zend_string is padded with 0.
https://github.com/php/php-src/blob/06428559e317b367bb54eb2bef4c33cd9c67e38d/ext/bcmath/libbcmath/src/num2str.c#L68
benchmark: https://github.com/php/php-src/pull/14132
## before
```
// 1
Time (mean ± σ): 551.0 ms ± 8.4 ms [User: 546.6 ms, System: 3.7 ms]
Range (min … max): 536.9 ms … 563.4 ms 10 runs
// 2
Time (mean ± σ): 610.8 ms ± 16.4 ms [User: 607.4 ms, System: 2.6 ms]
Range (min … max): 599.4 ms … 653.7 ms 10 runs
// 3
Time (mean ± σ): 707.8 ms ± 21.3 ms [User: 704.4 ms, System: 2.6 ms]
Range (min … max): 681.0 ms … 754.1 ms 10 runs
```
## after
```
// 1
Time (mean ± σ): 523.3 ms ± 3.9 ms [User: 519.3 ms, System: 3.2 ms]
Range (min … max): 518.5 ms … 529.4 ms 10 runs
// 2
Time (mean ± σ): 591.5 ms ± 13.4 ms [User: 587.8 ms, System: 2.9 ms]
Range (min … max): 575.3 ms … 620.9 ms 10 runs
// 3
Time (mean ± σ): 685.9 ms ± 10.2 ms [User: 681.8 ms, System: 3.3 ms]
Range (min … max): 668.6 ms … 696.7 ms 10 runs
```