Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/random/randomizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ PHP_METHOD(Random_Randomizer, shuffleArray)
Z_PARAM_ARRAY(array)
ZEND_PARSE_PARAMETERS_END();

ZVAL_DUP(return_value, array);
RETVAL_ARR(zend_array_dup(Z_ARRVAL_P(array)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular reason for not using SEPARATE_ARRAY()? This would avoid a duplication when it's not stricly necessary, e.g.:

$r->shuffleArray(range(0,10));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a specific suggestion as how to adjust the code to leverage SEPARATE_ARRAY? My attempts all lead to either memory unsafety or SEPARATE_ARRAY not providing a value-add.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right indeed, there SEPARATE_ARRAY would not make sense here.

if (!php_array_data_shuffle(randomizer->engine, return_value)) {
RETURN_THROWS();
}
Expand Down
Loading