avm2: `Vector.sort` actually *does* calculate an indexed sort array, but then discards it.

Normally we could skip sorting, but values in the vector may have side effects when coerced. So we need to make sure coercions run, at least.
This commit is contained in:
David Wendt 2021-08-03 18:35:21 -04:00 committed by kmeisthax
parent 280fbbde45
commit e087a27e56
1 changed files with 6 additions and 6 deletions

View File

@ -867,12 +867,6 @@ pub fn sort<'gc>(
)
};
//NOTE: RETURNINDEXEDARRAY is actually unimplemented in Flash Player
//and will turn the sort into a no-op.
if options.contains(SortOptions::RETURN_INDEXED_ARRAY) {
return Ok(this.into());
}
let compare = move |activation: &mut Activation<'_, 'gc, '_>, a, b| {
if let Some(compare_fnc) = compare_fnc {
let order = compare_fnc
@ -918,6 +912,12 @@ pub fn sort<'gc>(
error_signal?;
//NOTE: RETURNINDEXEDARRAY does NOT actually return anything useful.
//The actual sorting still happens, but the results are discarded.
if options.contains(SortOptions::RETURN_INDEXED_ARRAY) {
return Ok(this.into());
}
if !options.contains(SortOptions::UNIQUE_SORT) || unique_sort_satisfied {
let mut vs = this
.as_vector_storage_mut(activation.context.gc_context)