Skip to content

Commit a0a1d90

Browse files
committed
Refactor zend_resolve_ce()
1 parent ac74551 commit a0a1d90

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

Zend/zend_execute.c

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -840,31 +840,25 @@ static zend_class_entry *resolve_single_class_type(zend_string *name, zend_class
840840
static zend_always_inline zend_class_entry* zend_resolve_ce(
841841
zend_property_info *info, zend_type *type) {
842842
zend_class_entry *ce;
843-
if (UNEXPECTED(ZEND_TYPE_HAS_NAME(*type))) {
844-
zend_string *name = ZEND_TYPE_NAME(*type);
845-
846-
if (ZSTR_HAS_CE_CACHE(name)) {
847-
ce = ZSTR_GET_CE_CACHE(name);
848-
if (!ce) {
849-
ce = zend_lookup_class_ex(name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
850-
if (UNEXPECTED(!ce)) {
851-
/* Cannot resolve */
852-
return NULL;
853-
}
854-
}
855-
} else {
856-
ce = resolve_single_class_type(name, info->ce);
857-
if (!ce) {
858-
/* Cannot resolve */
859-
return NULL;
860-
}
861-
if (!(info->ce->ce_flags & ZEND_ACC_IMMUTABLE)) {
862-
zend_string_release(name);
863-
ZEND_TYPE_SET_CE(*type, ce);
864-
}
843+
zend_string *name = NULL;
844+
845+
if (UNEXPECTED(!ZEND_TYPE_HAS_NAME(*type))) {
846+
return ZEND_TYPE_CE(*type);
847+
}
848+
849+
name = ZEND_TYPE_NAME(*type);
850+
851+
if (ZSTR_HAS_CE_CACHE(name)) {
852+
ce = ZSTR_GET_CE_CACHE(name);
853+
if (!ce) {
854+
ce = zend_lookup_class_ex(name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
865855
}
866856
} else {
867-
ce = ZEND_TYPE_CE(*type);
857+
ce = resolve_single_class_type(name, info->ce);
858+
if (ce && !(info->ce->ce_flags & ZEND_ACC_IMMUTABLE)) {
859+
zend_string_release(name);
860+
ZEND_TYPE_SET_CE(*type, ce);
861+
}
868862
}
869863
return ce;
870864
}

0 commit comments

Comments
 (0)