mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2025-02-17 10:18:13 +00:00
The overhead of de duplication operation is too high in function PushToNativePointerList
Make sure there is no repetition where the interface is called https://gitee.com/openharmony/ark_js_runtime/issues/I56ARS?from=project-issue Signed-off-by: yingguofeng@huawei.com <yingguofeng@huawei.com> Change-Id: Ib9b248beffe62be5c7826782a0f3ab639f7c3d30
This commit is contained in:
parent
e9f1f0be86
commit
b967a1c7c5
@ -539,9 +539,6 @@ void EcmaVM::ProcessReferences(const WeakRootVisitor &v0)
|
||||
|
||||
void EcmaVM::PushToNativePointerList(JSNativePointer *array)
|
||||
{
|
||||
if (std::find(nativePointerList_.begin(), nativePointerList_.end(), array) != nativePointerList_.end()) {
|
||||
return;
|
||||
}
|
||||
nativePointerList_.emplace_back(array);
|
||||
}
|
||||
|
||||
@ -549,6 +546,8 @@ void EcmaVM::RemoveFromNativePointerList(JSNativePointer *array)
|
||||
{
|
||||
auto iter = std::find(nativePointerList_.begin(), nativePointerList_.end(), array);
|
||||
if (iter != nativePointerList_.end()) {
|
||||
JSNativePointer *object = *iter;
|
||||
object->Destroy();
|
||||
nativePointerList_.erase(iter);
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,6 @@ void JSArrayBuffer::Attach(JSThread *thread, uint32_t arrayBufferByteLength, JST
|
||||
ASSERT(arrayBufferData.IsNativePointer());
|
||||
SetArrayBufferByteLength(arrayBufferByteLength);
|
||||
SetArrayBufferData(thread, arrayBufferData);
|
||||
EcmaVM *vm = thread->GetEcmaVM();
|
||||
vm->PushToNativePointerList(JSNativePointer::Cast(arrayBufferData.GetHeapObject()));
|
||||
}
|
||||
|
||||
void JSArrayBuffer::Detach(JSThread *thread)
|
||||
@ -52,12 +50,6 @@ void JSArrayBuffer::Detach(JSThread *thread)
|
||||
return;
|
||||
}
|
||||
|
||||
EcmaVM *vm = thread->GetEcmaVM();
|
||||
// remove vm's control over arrayBufferData.
|
||||
JSNativePointer *jsNativePointer = JSNativePointer::Cast(arrayBufferData.GetHeapObject());
|
||||
vm->RemoveFromNativePointerList(jsNativePointer);
|
||||
jsNativePointer->Destroy();
|
||||
|
||||
SetArrayBufferData(thread, JSTaggedValue::Null());
|
||||
SetArrayBufferByteLength(0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user