Skip to content

Commit e5e7a93

Browse files
committed
Use zend_hash_lookup in simplexml
Prevents a double lookup.
1 parent 1a61d29 commit e5e7a93

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

ext/simplexml/simplexml.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -954,18 +954,16 @@ static void get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval *
954954

955955
static void sxe_properties_add(HashTable *rv, char *name, int namelen, zval *value) /* {{{ */
956956
{
957-
zend_string *key;
958-
zval *data_ptr;
959-
960-
key = zend_string_init(name, namelen, 0);
961-
if ((data_ptr = zend_hash_find(rv, key)) != NULL) {
957+
zend_string *key = zend_string_init(name, namelen, 0);
958+
zval *data_ptr = zend_hash_lookup(rv, key);
959+
if (!Z_ISNULL_P(data_ptr)) {
962960
if (Z_TYPE_P(data_ptr) == IS_ARRAY) {
963961
zend_hash_next_index_insert_new(Z_ARRVAL_P(data_ptr), value);
964962
} else {
965963
ZVAL_ARR(data_ptr, zend_new_pair(data_ptr, value));
966964
}
967965
} else {
968-
zend_hash_add_new(rv, key, value);
966+
ZVAL_COPY_VALUE(data_ptr, value);
969967
}
970968
zend_string_release_ex(key, 0);
971969
}

0 commit comments

Comments
 (0)