- Notifications
You must be signed in to change notification settings - Fork8k
Commitbaa5319
authored
json: Improve performance of
`tmp` can only ever be non-undef if there's a hooked object property, which isalready an `UNEXPECTED()` case. Keep track of whether this case is hit or notto avoid needlessly calling `zval_ptr_dtor()`.For: <?php $len = 0; for ($i = 0; $i < 3_000_000; $i++) { $len += strlen(json_encode(array_fill(0, 20, []))); } var_dump($len);This is ~1.02 faster for a gcc 13.3 release build on a Intel(R) Core(TM)i7-1365U. Benchmark 1: /tmp/bench/before /tmp/bench/test6.php Time (mean ± σ): 762.7 ms ± 3.2 ms [User: 758.5 ms, System: 2.8 ms] Range (min … max): 759.2 ms … 769.3 ms 10 runs Benchmark 2: /tmp/bench/after /tmp/bench/test6.php Time (mean ± σ): 748.3 ms ± 9.0 ms [User: 744.3 ms, System: 3.1 ms] Range (min … max): 740.8 ms … 766.2 ms 10 runs Summary /tmp/bench/after /tmp/bench/test6.php ran 1.02 ± 0.01 times faster than /tmp/bench/before /tmp/bench/test6.phpphp_json_encode_array()
for non-hooked fields (#20105)1 parent4b2bb20 commitbaa5319
1 file changed
+5
-1
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
243 | 243 |
| |
244 | 244 |
| |
245 | 245 |
| |
| 246 | + | |
246 | 247 |
| |
247 | 248 |
| |
248 | 249 |
| |
| |||
264 | 265 |
| |
265 | 266 |
| |
266 | 267 |
| |
| 268 | + | |
267 | 269 |
| |
268 | 270 |
| |
269 | 271 |
| |
| |||
303 | 305 |
| |
304 | 306 |
| |
305 | 307 |
| |
306 |
| - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
307 | 311 |
| |
308 | 312 |
| |
309 | 313 |
| |
|
0 commit comments
Comments
(0)