Skip to content

Commit f02be57

Browse files
committed
Call handler directly if it's defined
1 parent 085034d commit f02be57

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

Zend/zend_vm_def.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8438,12 +8438,7 @@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_COUNT, CONST|TMPVAR|CV, UNUSED)
84388438
zend_object *zobj = Z_OBJ_P(op1);
84398439
/* First, check if the handler is defined as it is faster */
84408440
if (zobj->handlers->count_elements) {
8441-
if (FAILURE == zobj->handlers->count_elements(zobj, &count)) {
8442-
zend_type_error("Parameter must be an array or an object that implements Countable");
8443-
}
8444-
if (UNEXPECTED(EG(exception))) {
8445-
count = 0;
8446-
}
8441+
zobj->handlers->count_elements(zobj, &count);
84478442
/* Otherwise check if the object implements Countable and call its count() method */
84488443
} else if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
84498444
zval retval;

Zend/zend_vm_execute.h

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9272,12 +9272,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CONST_
92729272
zend_object *zobj = Z_OBJ_P(op1);
92739273
/* First, check if the handler is defined as it is faster */
92749274
if (zobj->handlers->count_elements) {
9275-
if (FAILURE == zobj->handlers->count_elements(zobj, &count)) {
9276-
zend_type_error("Parameter must be an array or an object that implements Countable");
9277-
}
9278-
if (UNEXPECTED(EG(exception))) {
9279-
count = 0;
9280-
}
9275+
zobj->handlers->count_elements(zobj, &count);
92819276
/* Otherwise check if the object implements Countable and call its count() method */
92829277
} else if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
92839278
zval retval;
@@ -16281,12 +16276,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_TMPVAR_UNUSED_HANDL
1628116276
zend_object *zobj = Z_OBJ_P(op1);
1628216277
/* First, check if the handler is defined as it is faster */
1628316278
if (zobj->handlers->count_elements) {
16284-
if (FAILURE == zobj->handlers->count_elements(zobj, &count)) {
16285-
zend_type_error("Parameter must be an array or an object that implements Countable");
16286-
}
16287-
if (UNEXPECTED(EG(exception))) {
16288-
count = 0;
16289-
}
16279+
zobj->handlers->count_elements(zobj, &count);
1629016280
/* Otherwise check if the object implements Countable and call its count() method */
1629116281
} else if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
1629216282
zval retval;
@@ -45041,12 +45031,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CV_UNUSED_HANDLER(Z
4504145031
zend_object *zobj = Z_OBJ_P(op1);
4504245032
/* First, check if the handler is defined as it is faster */
4504345033
if (zobj->handlers->count_elements) {
45044-
if (FAILURE == zobj->handlers->count_elements(zobj, &count)) {
45045-
zend_type_error("Parameter must be an array or an object that implements Countable");
45046-
}
45047-
if (UNEXPECTED(EG(exception))) {
45048-
count = 0;
45049-
}
45034+
zobj->handlers->count_elements(zobj, &count);
4505045035
/* Otherwise check if the object implements Countable and call its count() method */
4505145036
} else if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
4505245037
zval retval;

0 commit comments

Comments
 (0)