Skip to content

Commit

Permalink
Preallocate result array size in simplexml xpath
Browse files Browse the repository at this point in the history
This is the simplexml version of 4dea42a.
  • Loading branch information
nielsdos committed Sep 9, 2023
1 parent 0ea268b commit d18bab5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ext/simplexml/simplexml.c
Expand Up @@ -1309,7 +1309,8 @@ PHP_METHOD(SimpleXMLElement, xpath)
result = retval->nodesetval;

if (result != NULL) {
array_init(return_value);
array_init_size(return_value, result->nodeNr);
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));

for (i = 0; i < result->nodeNr; ++i) {
nodeptr = result->nodeTab[i];
Expand Down

0 comments on commit d18bab5

Please sign in to comment.