Hello!
PHP 8.1 supports array unpacking with keys. I guess that is very similar to
array_merge()
, but for some reason array_merge()
is 50% slower than
unpacking.
So my question is: is there some way to optimize the engine so
array_merge()
can work like unpacking?
Thanks!
Hi David,
It would be useful if you could provide your measurements and the way you
arrived at such results. A quick test doesn't seem to support your
findings: https://3v4l.org/v5m9f#v8.1.8
There are already a number of optimizations in array_merge. It might depend
on the actual test data that you used. Maybe a specific path needs to be
optimized. Please provide some more details.
Regards,
Kamil
There are already a number of optimizations in array_merge. It might
depend on the actual test data that you used. Maybe a specific path needs
to be optimized. Please provide some more details.
You are right. I do not know how I tested before, but actually,
array_merge()
is bit faster than array unpacking.
Atenciosamente,
David Rodrigues
Em seg., 1 de ago. de 2022 às 14:45, Kamil Tekiela tekiela246@gmail.com
escreveu:
Hi David,
It would be useful if you could provide your measurements and the way you
arrived at such results. A quick test doesn't seem to support your
findings: https://3v4l.org/v5m9f#v8.1.8There are already a number of optimizations in array_merge. It might
depend on the actual test data that you used. Maybe a specific path needs
to be optimized. Please provide some more details.Regards,
Kamil