Skip to content

Commit 5f4f373

Browse files
committed
Call handler directly if it's defined
1 parent 95b30d9 commit 5f4f373

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
@@ -8433,12 +8433,7 @@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_COUNT, CONST|TMPVAR|CV, UNUSED)
84338433
zend_object *zobj = Z_OBJ_P(op1);
84348434
/* First, check if the handler is defined as it is faster */
84358435
if (zobj->handlers->count_elements) {
8436-
if (FAILURE == zobj->handlers->count_elements(zobj, &count)) {
8437-
zend_type_error("Parameter must be an array or an object that implements Countable");
8438-
}
8439-
if (UNEXPECTED(EG(exception))) {
8440-
count = 0;
8441-
}
8436+
zobj->handlers->count_elements(zobj, &count);
84428437
/* Otherwise check if the object implements Countable and call its count() method */
84438438
} else if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
84448439
zval retval;

Zend/zend_vm_execute.h

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9265,12 +9265,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CONST_
92659265
zend_object *zobj = Z_OBJ_P(op1);
92669266
/* First, check if the handler is defined as it is faster */
92679267
if (zobj->handlers->count_elements) {
9268-
if (FAILURE == zobj->handlers->count_elements(zobj, &count)) {
9269-
zend_type_error("Parameter must be an array or an object that implements Countable");
9270-
}
9271-
if (UNEXPECTED(EG(exception))) {
9272-
count = 0;
9273-
}
9268+
zobj->handlers->count_elements(zobj, &count);
92749269
/* Otherwise check if the object implements Countable and call its count() method */
92759270
} else if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
92769271
zval retval;
@@ -16280,12 +16275,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_TMPVAR_UNUSED_HANDL
1628016275
zend_object *zobj = Z_OBJ_P(op1);
1628116276
/* First, check if the handler is defined as it is faster */
1628216277
if (zobj->handlers->count_elements) {
16283-
if (FAILURE == zobj->handlers->count_elements(zobj, &count)) {
16284-
zend_type_error("Parameter must be an array or an object that implements Countable");
16285-
}
16286-
if (UNEXPECTED(EG(exception))) {
16287-
count = 0;
16288-
}
16278+
zobj->handlers->count_elements(zobj, &count);
1628916279
/* Otherwise check if the object implements Countable and call its count() method */
1629016280
} else if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
1629116281
zval retval;
@@ -45070,12 +45060,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CV_UNUSED_HANDLER(Z
4507045060
zend_object *zobj = Z_OBJ_P(op1);
4507145061
/* First, check if the handler is defined as it is faster */
4507245062
if (zobj->handlers->count_elements) {
45073-
if (FAILURE == zobj->handlers->count_elements(zobj, &count)) {
45074-
zend_type_error("Parameter must be an array or an object that implements Countable");
45075-
}
45076-
if (UNEXPECTED(EG(exception))) {
45077-
count = 0;
45078-
}
45063+
zobj->handlers->count_elements(zobj, &count);
4507945064
/* Otherwise check if the object implements Countable and call its count() method */
4508045065
} else if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
4508145066
zval retval;

0 commit comments

Comments
 (0)