ext/standard: Optimize result-row construction in array_map() with a null callback - #23809
LamentXU123 wants to merge 3 commits into
Conversation
| if (!ZEND_FCI_INITIALIZED(fci)) { | ||
| uint32_t *array_pos = ecalloc(n_arrays, sizeof(HashPosition)); | ||
| zval zv; | ||
| zval zv = {0}; |
There was a problem hiding this comment.
This looks a bit suspicious, why did you need to do this?
There was a problem hiding this comment.
from what I observe it is assigned in every path indeed.
There was a problem hiding this comment.
This looks a bit suspicious, why did you need to do this?
It's because later in ZEND_HASH_FILL_ADD copy the value of zv and it's not initialized. So GCC warns on it.
But anyways, we don't need to consider this now.
There was a problem hiding this comment.
Right, I was curious because it didn't seem necessary and felt like something uninitialized ended up somewhere. But apparently it's just the compiler not being smart enough.
There was a problem hiding this comment.
I think you can optimise that part too (i.e. return_value initialisation is optimised).
When
array_map()receives a null callback and multiple arrays, each result row has a known size and consecutive integer keys.In this case we just init each value once. No regressions intended.