Skip to content

Commit 466277c

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 2523491 commit 466277c

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
@@ -6920,7 +6920,7 @@ PHP_FUNCTION(array_map)
69206920
ZVAL_NULL(&params[i]);
69216921
break;
69226922
} else if (Z_TYPE(Z_ARRVAL(arrays[i])->arPacked[pos]) != IS_UNDEF) {
6923-
ZVAL_COPY(&params[i], &Z_ARRVAL(arrays[i])->arPacked[pos]);
6923+
ZVAL_COPY_VALUE(&params[i], &Z_ARRVAL(arrays[i])->arPacked[pos]);
69246924
array_pos[i] = pos + 1;
69256925
break;
69266926
}
@@ -6932,7 +6932,7 @@ PHP_FUNCTION(array_map)
69326932
ZVAL_NULL(&params[i]);
69336933
break;
69346934
} else if (Z_TYPE(Z_ARRVAL(arrays[i])->arData[pos].val) != IS_UNDEF) {
6935-
ZVAL_COPY(&params[i], &Z_ARRVAL(arrays[i])->arData[pos].val);
6935+
ZVAL_COPY_VALUE(&params[i], &Z_ARRVAL(arrays[i])->arData[pos].val);
69366936
array_pos[i] = pos + 1;
69376937
break;
69386938
}
@@ -6952,15 +6952,8 @@ PHP_FUNCTION(array_map)
69526952
if (Z_TYPE(result) == IS_UNDEF) {
69536953
efree(array_pos);
69546954
zend_array_destroy(Z_ARR_P(return_value));
6955-
for (i = 0; i < n_arrays; i++) {
6956-
zval_ptr_dtor(&params[i]);
6957-
}
69586955
efree(params);
69596956
RETURN_NULL();
6960-
} else {
6961-
for (i = 0; i < n_arrays; i++) {
6962-
zval_ptr_dtor(&params[i]);
6963-
}
69646957
}
69656958

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

0 commit comments

Comments
 (0)