Skip to content

Commit bdbc082

Browse files
committed
usort RC1
1 parent dfa9c8a commit bdbc082

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ext/standard/array.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,8 +906,11 @@ static void php_usort(INTERNAL_FUNCTION_PARAMETERS, bucket_compare_func_t compar
906906
RETURN_TRUE;
907907
}
908908

909-
/* Copy array, so the in-place modifications will not be visible to the callback function */
910-
arr = zend_array_dup(arr);
909+
/* Copy array, so the in-place modifications will not be visible to the callback function.
910+
* Unless there are no other references since we know for sure it won't be visible. */
911+
if (!zend_may_modify_array_in_place(array)) {
912+
arr = zend_array_dup(arr);
913+
}
911914

912915
zend_hash_sort(arr, compare_func, renumber);
913916

0 commit comments

Comments
 (0)