hoist the condition in FindLastRawData

Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IATELU
Signed-off-by: ZhouGuangyuan <zhouguangyuan1@huawei.com>
Change-Id: I6832989495a438ebad716557c64f1816da001be6
This commit is contained in:
zhouguangyuan 2024-09-24 22:20:56 +08:00
parent 5902e505c9
commit 33eebac202

View File

@ -844,7 +844,9 @@ JSTaggedValue JSStableArray::FindLastRawData(IndexOfContext &ctx, Predicate &&pr
JSTaggedType *data = nullptr;
JSTaggedValue elementsValue = JSHandle<JSObject>::Cast(ctx.receiver)->GetElements();
ElementsKind kind = ElementsKind::GENERIC;
bool isMutant = false;
if (elementsValue.IsMutantTaggedArray()) {
isMutant = true;
JSHandle<MutantTaggedArray> elements(ctx.thread, JSHandle<JSObject>::Cast(ctx.receiver)->GetElements());
data = elements->GetData();
kind = JSHandle<JSObject>::Cast(ctx.receiver)->GetClass()->GetElementsKind();
@ -859,7 +861,7 @@ JSTaggedValue JSStableArray::FindLastRawData(IndexOfContext &ctx, Predicate &&pr
JSMutableHandle<JSTaggedValue> indexHandle(ctx.thread, JSTaggedValue::Undefined());
for (JSTaggedType *cur = beforeLast; cur > beforeFirst; --cur) {
JSTaggedValue convertedCur = JSTaggedValue(*cur);
if (elementsValue.IsMutantTaggedArray()) {
if (isMutant) {
convertedCur = ElementAccessor::GetTaggedValueWithElementsKind(*cur, kind);
}
if (LIKELY(convertedCur.GetRawData() != JSTaggedValue::VALUE_HOLE)) {