mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:17:34 +00:00
LibJS: Remove redundant VM& parameter from array_merge_sort()
This is covered by GlobalObject& just fine.
This commit is contained in:
parent
105c516a78
commit
aa5d5bf1c8
2 changed files with 7 additions and 5 deletions
|
@ -867,13 +867,15 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reverse)
|
||||||
return this_object;
|
return this_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThrowCompletionOr<void> array_merge_sort(VM& vm, GlobalObject& global_object, FunctionObject* compare_func, MarkedVector<Value>& arr_to_sort)
|
ThrowCompletionOr<void> array_merge_sort(GlobalObject& global_object, FunctionObject* compare_func, MarkedVector<Value>& arr_to_sort)
|
||||||
{
|
{
|
||||||
// FIXME: it would probably be better to switch to insertion sort for small arrays for
|
// FIXME: it would probably be better to switch to insertion sort for small arrays for
|
||||||
// better performance
|
// better performance
|
||||||
if (arr_to_sort.size() <= 1)
|
if (arr_to_sort.size() <= 1)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
auto& vm = global_object.vm();
|
||||||
|
|
||||||
MarkedVector<Value> left(vm.heap());
|
MarkedVector<Value> left(vm.heap());
|
||||||
MarkedVector<Value> right(vm.heap());
|
MarkedVector<Value> right(vm.heap());
|
||||||
|
|
||||||
|
@ -888,8 +890,8 @@ ThrowCompletionOr<void> array_merge_sort(VM& vm, GlobalObject& global_object, Fu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TRY(array_merge_sort(vm, global_object, compare_func, left));
|
TRY(array_merge_sort(global_object, compare_func, left));
|
||||||
TRY(array_merge_sort(vm, global_object, compare_func, right));
|
TRY(array_merge_sort(global_object, compare_func, right));
|
||||||
|
|
||||||
arr_to_sort.clear();
|
arr_to_sort.clear();
|
||||||
|
|
||||||
|
@ -990,7 +992,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::sort)
|
||||||
// to be stable. FIXME: when initially scanning through the array, maintain a flag
|
// to be stable. FIXME: when initially scanning through the array, maintain a flag
|
||||||
// for if an unstable sort would be indistinguishable from a stable sort (such as just
|
// for if an unstable sort would be indistinguishable from a stable sort (such as just
|
||||||
// just strings or numbers), and in that case use quick sort instead for better performance.
|
// just strings or numbers), and in that case use quick sort instead for better performance.
|
||||||
TRY(array_merge_sort(vm, global_object, callback.is_undefined() ? nullptr : &callback.as_function(), items));
|
TRY(array_merge_sort(global_object, callback.is_undefined() ? nullptr : &callback.as_function(), items));
|
||||||
|
|
||||||
for (size_t j = 0; j < items.size(); ++j)
|
for (size_t j = 0; j < items.size(); ++j)
|
||||||
TRY(object->set(j, items[j], Object::ShouldThrowExceptions::Yes));
|
TRY(object->set(j, items[j], Object::ShouldThrowExceptions::Yes));
|
||||||
|
|
|
@ -58,6 +58,6 @@ private:
|
||||||
JS_DECLARE_NATIVE_FUNCTION(group_to_map);
|
JS_DECLARE_NATIVE_FUNCTION(group_to_map);
|
||||||
};
|
};
|
||||||
|
|
||||||
ThrowCompletionOr<void> array_merge_sort(VM&, GlobalObject&, FunctionObject* compare_func, MarkedVector<Value>& arr_to_sort);
|
ThrowCompletionOr<void> array_merge_sort(GlobalObject&, FunctionObject* compare_func, MarkedVector<Value>& arr_to_sort);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue