Fix GH-21223: ext/mbstring replace alloca with safe_emalloc in mb_guess_encoding_for_strings#21224
Fix GH-21223: ext/mbstring replace alloca with safe_emalloc in mb_guess_encoding_for_strings#21224jordikroon wants to merge 1 commit intophp:masterfrom
Conversation
|
@jordikroon, thanks for the PR. Some questions:
If there is no performance impact, then I would definitely agree with moving to Speaking of which... is there performance impact to running |
|
@alexdowad I hope this answers your questions.
Lastly as for the performance impact. It seems non-negligible and both before and after seem be even in performance. Sometimes one is faster than the other. But the longer the input, the slower it will become.
That said. Duplicate values do seem to affect performance. As in a single UTF-8 is notably faster than a list of |
|
@jordikroon Hmm. You said for macOS you found a threshold of 208,629? But your test code uses an array with 50,000 copies of the string "UTF-8". |
|
Where did you see 50.000 copies? The test file and example show 500.000 copies. |
Ah 😅 That explains it. When I have some time, I intend to benchmark this change myself as an additional point of reference to assess the impact. |
Fixes #21223