Repository navigation
Conversation
|
Some numbers, release build without opcache, best of 7 runs, in ms. 8 elements, 1M iterations:
100 elements, 100k iterations:
|
| src->nInternalPointer == 0 && | ||
| src->nNextFreeElement == next_free) { |
There was a problem hiding this comment.
changed code uses a mix of tabs and spaces
Skip the duplicate and merge when either operand is empty, unless sharing would change the internal pointer or next free index.
949605d to
7a6c78c
Compare
ndossche
left a comment
There was a problem hiding this comment.
This looks so complicated and I'm still not convinced it's correct; I can't follow the soundness of the second case.
The first case definitely isn't correct. zend_array_dup() deals with references. So this behaviour changes:
$x = 1;
$b = ['a' => &$x];
$r = [] + $b;
unset($x);
$b['a'] = 5;
echo $r['a'];| if (zend_hash_num_elements(Z_ARRVAL_P(op2)) == 0 && | ||
| Z_ARRVAL_P(op1)->nInternalPointer < Z_ARRVAL_P(op1)->nNumUsed) { | ||
| /* $a += [] or $a + [], unless the internal pointer is past the | ||
| * end as zend_array_dup() would reset it */ |
There was a problem hiding this comment.
These comments make it sound like the internal pointer is the only thing that changes, which is misleading
ah good point, it is ... I ll see about these. |
Skip the duplicate and merge when either operand is empty, unless sharing would change the internal pointer or next free index.