Skip to content

Commit 2331ec1

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 bc458e5 commit 2331ec1

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
@@ -6927,7 +6927,7 @@ PHP_FUNCTION(array_map)
69276927
ZVAL_NULL(&params[i]);
69286928
break;
69296929
} else if (Z_TYPE(Z_ARRVAL(arrays[i])->arPacked[pos]) != IS_UNDEF) {
6930-
ZVAL_COPY(&params[i], &Z_ARRVAL(arrays[i])->arPacked[pos]);
6930+
ZVAL_COPY_VALUE(&params[i], &Z_ARRVAL(arrays[i])->arPacked[pos]);
69316931
array_pos[i] = pos + 1;
69326932
break;
69336933
}
@@ -6939,7 +6939,7 @@ PHP_FUNCTION(array_map)
69396939
ZVAL_NULL(&params[i]);
69406940
break;
69416941
} else if (Z_TYPE(Z_ARRVAL(arrays[i])->arData[pos].val) != IS_UNDEF) {
6942-
ZVAL_COPY(&params[i], &Z_ARRVAL(arrays[i])->arData[pos].val);
6942+
ZVAL_COPY_VALUE(&params[i], &Z_ARRVAL(arrays[i])->arData[pos].val);
69436943
array_pos[i] = pos + 1;
69446944
break;
69456945
}
@@ -6959,15 +6959,8 @@ PHP_FUNCTION(array_map)
69596959
if (Z_TYPE(result) == IS_UNDEF) {
69606960
efree(array_pos);
69616961
zend_array_destroy(Z_ARR_P(return_value));
6962-
for (i = 0; i < n_arrays; i++) {
6963-
zval_ptr_dtor(&params[i]);
6964-
}
69656962
efree(params);
69666963
RETURN_NULL();
6967-
} else {
6968-
for (i = 0; i < n_arrays; i++) {
6969-
zval_ptr_dtor(&params[i]);
6970-
}
69716964
}
69726965

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

0 commit comments

Comments
 (0)