Skip to content

Commit 917deca

Browse files
committed
Remove unnecessary zend_array_count() uses
The function is still used by var.c in some places.
1 parent 51c3676 commit 917deca

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Zend/zend_vm_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8915,7 +8915,7 @@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_COUNT, CONST|TMPVAR|CV, UNUSED)
89158915

89168916
while (1) {
89178917
if (Z_TYPE_P(op1) == IS_ARRAY) {
8918-
count = zend_array_count(Z_ARRVAL_P(op1));
8918+
count = zend_hash_num_elements(Z_ARRVAL_P(op1));
89198919
break;
89208920
} else if (Z_TYPE_P(op1) == IS_OBJECT) {
89218921
zend_object *zobj = Z_OBJ_P(op1);

Zend/zend_vm_execute.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10325,7 +10325,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CONST_
1032510325

1032610326
while (1) {
1032710327
if (Z_TYPE_P(op1) == IS_ARRAY) {
10328-
count = zend_array_count(Z_ARRVAL_P(op1));
10328+
count = zend_hash_num_elements(Z_ARRVAL_P(op1));
1032910329
break;
1033010330
} else if (Z_TYPE_P(op1) == IS_OBJECT) {
1033110331
zend_object *zobj = Z_OBJ_P(op1);
@@ -17566,7 +17566,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_TMPVAR_UNUSED_HANDL
1756617566

1756717567
while (1) {
1756817568
if (Z_TYPE_P(op1) == IS_ARRAY) {
17569-
count = zend_array_count(Z_ARRVAL_P(op1));
17569+
count = zend_hash_num_elements(Z_ARRVAL_P(op1));
1757017570
break;
1757117571
} else if (Z_TYPE_P(op1) == IS_OBJECT) {
1757217572
zend_object *zobj = Z_OBJ_P(op1);
@@ -47378,7 +47378,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_COUNT_SPEC_CV_UNUSED_HANDLER(Z
4737847378

4737947379
while (1) {
4738047380
if (Z_TYPE_P(op1) == IS_ARRAY) {
47381-
count = zend_array_count(Z_ARRVAL_P(op1));
47381+
count = zend_hash_num_elements(Z_ARRVAL_P(op1));
4738247382
break;
4738347383
} else if (Z_TYPE_P(op1) == IS_OBJECT) {
4738447384
zend_object *zobj = Z_OBJ_P(op1);

ext/phar/phar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ void phar_metadata_tracker_try_ensure_has_serialized_data(phar_metadata_tracker
601601
*/
602602
int phar_metadata_tracker_unserialize_or_copy(phar_metadata_tracker *tracker, zval *metadata, int persistent, HashTable *unserialize_options, const char* method_name) /* {{{ */
603603
{
604-
const zend_bool has_unserialize_options = unserialize_options != NULL && zend_array_count(unserialize_options) > 0;
604+
const zend_bool has_unserialize_options = unserialize_options != NULL && zend_hash_num_elements(unserialize_options) > 0;
605605
/* It should be impossible to create a zval in a persistent phar/entry. */
606606
ZEND_ASSERT(!persistent || Z_ISUNDEF(tracker->val));
607607

ext/standard/array.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ PHPAPI zend_long php_count_recursive(HashTable *ht) /* {{{ */
659659
GC_PROTECT_RECURSION(ht);
660660
}
661661

662-
cnt = zend_array_count(ht);
662+
cnt = zend_hash_num_elements(ht);
663663
ZEND_HASH_FOREACH_VAL(ht, element) {
664664
ZVAL_DEREF(element);
665665
if (Z_TYPE_P(element) == IS_ARRAY) {
@@ -693,7 +693,7 @@ PHP_FUNCTION(count)
693693
switch (Z_TYPE_P(array)) {
694694
case IS_ARRAY:
695695
if (mode != COUNT_RECURSIVE) {
696-
cnt = zend_array_count(Z_ARRVAL_P(array));
696+
cnt = zend_hash_num_elements(Z_ARRVAL_P(array));
697697
} else {
698698
cnt = php_count_recursive(Z_ARRVAL_P(array));
699699
}

0 commit comments

Comments
 (0)