Skip to content

Commit f4c3097

Browse files
committed
array_map: Avoid needing refcounted copies and cleanup
Since this will be copied on the call frame, a refcounted copy is not necessary.
1 parent a09cc6e commit f4c3097

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

ext/standard/array.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6928,7 +6928,7 @@ PHP_FUNCTION(array_map)
69286928
ZVAL_NULL(&params[i]);
69296929
break;
69306930
} else if (Z_TYPE(Z_ARRVAL(arrays[i])->arPacked[pos]) != IS_UNDEF) {
6931-
ZVAL_COPY(&params[i], &Z_ARRVAL(arrays[i])->arPacked[pos]);
6931+
ZVAL_COPY_VALUE(&params[i], &Z_ARRVAL(arrays[i])->arPacked[pos]);
69326932
array_pos[i] = pos + 1;
69336933
break;
69346934
}
@@ -6940,7 +6940,7 @@ PHP_FUNCTION(array_map)
69406940
ZVAL_NULL(&params[i]);
69416941
break;
69426942
} else if (Z_TYPE(Z_ARRVAL(arrays[i])->arData[pos].val) != IS_UNDEF) {
6943-
ZVAL_COPY(&params[i], &Z_ARRVAL(arrays[i])->arData[pos].val);
6943+
ZVAL_COPY_VALUE(&params[i], &Z_ARRVAL(arrays[i])->arData[pos].val);
69446944
array_pos[i] = pos + 1;
69456945
break;
69466946
}
@@ -6960,15 +6960,8 @@ PHP_FUNCTION(array_map)
69606960
if (Z_TYPE(result) == IS_UNDEF) {
69616961
efree(array_pos);
69626962
zend_array_destroy(Z_ARR_P(return_value));
6963-
for (i = 0; i < n_arrays; i++) {
6964-
zval_ptr_dtor(&params[i]);
6965-
}
69666963
efree(params);
69676964
RETURN_NULL();
6968-
} else {
6969-
for (i = 0; i < n_arrays; i++) {
6970-
zval_ptr_dtor(&params[i]);
6971-
}
69726965
}
69736966

69746967
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &result);

0 commit comments

Comments
 (0)