Skip to content

Commit d18bab5

Browse files
committed
Preallocate result array size in simplexml xpath
This is the simplexml version of 4dea42a.
1 parent 0ea268b commit d18bab5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ext/simplexml/simplexml.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,8 @@ PHP_METHOD(SimpleXMLElement, xpath)
13091309
result = retval->nodesetval;
13101310

13111311
if (result != NULL) {
1312-
array_init(return_value);
1312+
array_init_size(return_value, result->nodeNr);
1313+
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
13131314

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

0 commit comments

Comments
 (0)