Skip to content

Commit 91a310e

Browse files
authored
Get rid of separate DOM HashPosition member (#18354)
Besides the fact that this is only used for DOM_NODESET and thus makes no sense of being on the iterator itself, it's also redundant now that we have the index member.
1 parent 2e7df9e commit 91a310e

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

ext/dom/dom_iterators.c

+5-8
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,8 @@ static void php_dom_iterator_move_forward(zend_object_iterator *iter) /* {{{ */
189189
objmap->nodetype != XML_NOTATION_NODE) {
190190
if (objmap->nodetype == DOM_NODESET) {
191191
HashTable *nodeht = Z_ARRVAL_P(&objmap->baseobj_zv);
192-
zval *entry;
193-
zend_hash_move_forward_ex(nodeht, &iterator->pos);
194-
if ((entry = zend_hash_get_current_data_ex(nodeht, &iterator->pos))) {
192+
zval *entry = zend_hash_index_find(nodeht, iterator->index);
193+
if (entry) {
195194
zval_ptr_dtor(&iterator->curobj);
196195
ZVAL_COPY(&iterator->curobj, entry);
197196
return;
@@ -263,8 +262,6 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, i
263262
dom_object *intern;
264263
dom_nnodemap_object *objmap;
265264
xmlNodePtr curnode=NULL;
266-
HashTable *nodeht;
267-
zval *entry;
268265
php_dom_iterator *iterator;
269266

270267
if (by_ref) {
@@ -284,9 +281,9 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, i
284281
if (objmap->nodetype != XML_ENTITY_NODE &&
285282
objmap->nodetype != XML_NOTATION_NODE) {
286283
if (objmap->nodetype == DOM_NODESET) {
287-
nodeht = Z_ARRVAL_P(&objmap->baseobj_zv);
288-
zend_hash_internal_pointer_reset_ex(nodeht, &iterator->pos);
289-
if ((entry = zend_hash_get_current_data_ex(nodeht, &iterator->pos))) {
284+
HashTable *nodeht = Z_ARRVAL_P(&objmap->baseobj_zv);
285+
zval *entry = zend_hash_index_find(nodeht, 0);
286+
if (entry) {
290287
ZVAL_COPY(&iterator->curobj, entry);
291288
}
292289
} else {

ext/dom/php_dom.h

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ typedef struct dom_nnodemap_object {
9797
typedef struct {
9898
zend_object_iterator intern;
9999
zval curobj;
100-
HashPosition pos;
101100
/* intern->index is only updated for FE_* opcodes, not for e.g. unpacking,
102101
* yet we need to track the position of the node relative to the start. */
103102
zend_ulong index;

0 commit comments

Comments
 (0)