Skip to content

Commit 7b6dc7b

Browse files
committed
Call handler directly if it's defined
1 parent 51199e2 commit 7b6dc7b

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
@@ -8391,12 +8391,7 @@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_COUNT, CONST|TMPVAR|CV, UNUSED)
83918391
zend_object *zobj = Z_OBJ_P(op1);
83928392
/* First, check if the handler is defined as it is faster */
83938393
if (zobj->handlers->count_elements) {
8394-
if (FAILURE == zobj->handlers->count_elements(zobj, &count)) {
8395-
zend_type_error("Parameter must be an array or an object that implements Countable");
8396-
}
8397-
if (UNEXPECTED(EG(exception))) {
8398-
count = 0;
8399-
}
8394+
zobj->handlers->count_elements(zobj, &count);
84008395
/* Otherwise check if the object implements Countable and call its count() method */
84018396
} else if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
84028397
zval retval;

Zend/zend_vm_execute.h

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9233,12 +9233,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CONST_
92339233
zend_object *zobj = Z_OBJ_P(op1);
92349234
/* First, check if the handler is defined as it is faster */
92359235
if (zobj->handlers->count_elements) {
9236-
if (FAILURE == zobj->handlers->count_elements(zobj, &count)) {
9237-
zend_type_error("Parameter must be an array or an object that implements Countable");
9238-
}
9239-
if (UNEXPECTED(EG(exception))) {
9240-
count = 0;
9241-
}
9236+
zobj->handlers->count_elements(zobj, &count);
92429237
/* Otherwise check if the object implements Countable and call its count() method */
92439238
} else if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
92449239
zval retval;
@@ -16248,12 +16243,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_TMPVAR_UNUSED_HANDL
1624816243
zend_object *zobj = Z_OBJ_P(op1);
1624916244
/* First, check if the handler is defined as it is faster */
1625016245
if (zobj->handlers->count_elements) {
16251-
if (FAILURE == zobj->handlers->count_elements(zobj, &count)) {
16252-
zend_type_error("Parameter must be an array or an object that implements Countable");
16253-
}
16254-
if (UNEXPECTED(EG(exception))) {
16255-
count = 0;
16256-
}
16246+
zobj->handlers->count_elements(zobj, &count);
1625716247
/* Otherwise check if the object implements Countable and call its count() method */
1625816248
} else if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
1625916249
zval retval;
@@ -44805,12 +44795,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CV_UNUSED_HANDLER(Z
4480544795
zend_object *zobj = Z_OBJ_P(op1);
4480644796
/* First, check if the handler is defined as it is faster */
4480744797
if (zobj->handlers->count_elements) {
44808-
if (FAILURE == zobj->handlers->count_elements(zobj, &count)) {
44809-
zend_type_error("Parameter must be an array or an object that implements Countable");
44810-
}
44811-
if (UNEXPECTED(EG(exception))) {
44812-
count = 0;
44813-
}
44798+
zobj->handlers->count_elements(zobj, &count);
4481444799
/* Otherwise check if the object implements Countable and call its count() method */
4481544800
} else if (zend_class_implements_interface(zobj->ce, zend_ce_countable)) {
4481644801
zval retval;

0 commit comments

Comments
 (0)