!10343 Array.sort 增加开关

Merge pull request !10343 from 刘智杰/array_sort
This commit is contained in:
openharmony_ci 2024-11-21 06:47:14 +00:00 committed by Gitee
commit 069558e438
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -2392,11 +2392,19 @@ JSTaggedValue BuiltinsArray::Sort(EcmaRuntimeCallInfo *argv)
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
// Array sort
#if ENABLE_NEXT_OPTIMIZATION
if (thisHandle->IsStableJSArray(thread)) {
JSStableArray::Sort(thread, thisHandle, callbackFnHandle);
} else {
JSArray::Sort(thread, JSHandle<JSTaggedValue>::Cast(thisObjHandle), callbackFnHandle);
}
#else
if (thisHandle->IsStableJSArray(thread) && callbackFnHandle->IsUndefined()) {
JSArray::SortElementsByObject(thread, thisObjHandle, callbackFnHandle);
} else {
JSArray::Sort(thread, JSHandle<JSTaggedValue>::Cast(thisObjHandle), callbackFnHandle);
}
#endif
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
return thisObjHandle.GetTaggedValue();
}