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:
parent
280fbbde45
commit
e087a27e56
|
@ -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| {
|
let compare = move |activation: &mut Activation<'_, 'gc, '_>, a, b| {
|
||||||
if let Some(compare_fnc) = compare_fnc {
|
if let Some(compare_fnc) = compare_fnc {
|
||||||
let order = compare_fnc
|
let order = compare_fnc
|
||||||
|
@ -918,6 +912,12 @@ pub fn sort<'gc>(
|
||||||
|
|
||||||
error_signal?;
|
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 {
|
if !options.contains(SortOptions::UNIQUE_SORT) || unique_sort_satisfied {
|
||||||
let mut vs = this
|
let mut vs = this
|
||||||
.as_vector_storage_mut(activation.context.gc_context)
|
.as_vector_storage_mut(activation.context.gc_context)
|
||||||
|
|
Loading…
Reference in New Issue