8000 Use zend_array_is_list() in soap instead of own is_map() (#18684) · iluuu1994/php-src@b156d37 · GitHub
[go: up one dir, main page]

Skip to content

Commit b156d37

Browse files
authored
Use zend_array_is_list() in soap instead of own is_map() (php#18684)
is_map() is just the inverse of zend_array_is_list().
1 parent 3d51ba3 commit b156d37

File tree

1 file changed

+5
-25
lines changed

1 file changed

+5
-25
lines changed

ext/soap/php_encoding.c

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ static xmlNodePtr to_xml_any(encodeTypePtr type, zval *data, int style, xmlNodeP
8383
static zval *guess_zval_convert(zval *ret, encodeTypePtr type, xmlNodePtr data);
8484
static xmlNodePtr guess_xml_convert(encodeTypePtr type, zval *data, int style, xmlNodePtr parent);
8585

86-
static int is_map(zval *array);
8786
static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *out_type);
8887

8988
static xmlNodePtr check_and_resolve_href(xmlNodePtr data);
@@ -1664,7 +1663,7 @@ static int model_to_xml_object(xmlNodePtr node, sdlContentModelPtr model, zval *
16641663
enc = model->u.element->encode;
16651664
if ((model->max_occurs == -1 || model->max_occurs > 1) &&
16661665
Z_TYPE_P(data) == IS_ARRAY &&
1667-
!is_map(data)) {
1666+
zend_array_is_list(Z_ARRVAL_P(data))) {
16681667
HashTable *ht = Z_ARRVAL_P(data);
16691668
zval *val;
16701669

@@ -1743,7 +1742,7 @@ static int model_to_xml_object(xmlNodePtr node, sdlContentModelPtr model, zval *
17431742
enc = get_conversion(XSD_ANYXML);
17441743
if ((model->max_occurs == -1 || model->max_occurs > 1) &&
17451744
Z_TYPE_P(data) == IS_ARRAY &&
1746-
!is_map(data)) {
1745+
zend_array_is_list(Z_ARRVAL_P(data))) {
17471746
HashTable *ht = Z_ARRVAL_P(data);
17481747
zval *val;
17491748

@@ -1918,7 +1917,7 @@ static xmlNodePtr to_xml_object(encodeTypePtr type, zval *data, int style, xmlNo
19181917
sdlTypePtr array_el;
19191918

19201919
if (Z_TYPE_P(data) == IS_ARRAY &&
1921-
!is_map(data) &&
1920+
zend_array_is_list(Z_ARRVAL_P(data)) &&
19221921
sdlType->attributes == NULL &&
19231922
sdlType->model != NULL &&
19241923
(array_el = model_array_element(sdlType->model)) != NULL) {
@@ -2028,7 +2027,7 @@ static xmlNodePtr guess_array_map(encodeTypePtr type, zval *data, int style, xml
20282027
encodePtr enc = NULL;
20292028

20302029
if (data && Z_TYPE_P(data) == IS_ARRAY) {
2031-
if (is_map(data)) {
2030+
if (!zend_array_is_list(Z_ARRVAL_P(data))) {
20322031
enc = get_conversion(APACHE_MAP);
20332032
} else {
20342033
enc = get_conversion(SOAP_ENC_ARRAY);
@@ -3551,25 +3550,6 @@ encodePtr get_conversion(int encode)
35513550
}
35523551
}
35533552

3554-
static int is_map(zval *array)
3555-
{
3556-
zend_ulong index;
3557-
zend_string *key;
3558-
zend_ulong i = 0;
3559-
3560-
if (HT_IS_PACKED(Z_ARRVAL_P(array)) && HT_IS_WITHOUT_HOLES(Z_ARRVAL_P(array))) {
3561-
return FALSE;
3562-
}
3563-
3564-
ZEND_HASH_FOREACH_KEY(Z_ARRVAL_P(array), index, key) {
3565-
if (key || index != i) {
3566-
return TRUE;
3567-
}
3568-
i++;
3569-
} ZEND_HASH_FOREACH_END();
3570-
return FALSE;
3571-
}
3572-
35733553
static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type)
35743554
{
35753555
HashTable *ht;
@@ -3611,7 +3591,7 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type)
36113591
cur_ns = NULL;
36123592
}
36133593

3614-
} else if (Z_TYPE_P(tmp) == IS_ARRAY && is_map(tmp)) {
3594+
} else if (Z_TYPE_P(tmp) == IS_ARRAY && !zend_array_is_list(Z_ARRVAL_P(tmp))) {
36153595
cur_type = APACHE_MAP;
36163596
cur_stype = NULL;
36173597
cur_ns = NULL;

0 commit comments

Comments
 (0)
0