diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-02-06 20:44:05 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-02-06 20:44:05 +0000 |
commit | f3f1869409a59adbfde4b2b546f30c81051aad14 (patch) | |
tree | da2ca002c530bc069d22044a77ed0349496c4912 /fxjs/fxjs_v8.cpp | |
parent | 837b1751975e4cbcb1ff56d0e68c1ac2b8dbd712 (diff) | |
download | pdfium-f3f1869409a59adbfde4b2b546f30c81051aad14.tar.xz |
Avoid needless malloc for v8:Global array.
They have move semantics, so they can directly be members of the array.
Change-Id: Ia73cbc06fd22665693ae1a4efe6a6f64eca1b5fb
Reviewed-on: https://pdfium-review.googlesource.com/25490
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/fxjs_v8.cpp')
-rw-r--r-- | fxjs/fxjs_v8.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/fxjs/fxjs_v8.cpp b/fxjs/fxjs_v8.cpp index 7869bab038..773f9025b1 100644 --- a/fxjs/fxjs_v8.cpp +++ b/fxjs/fxjs_v8.cpp @@ -417,9 +417,7 @@ void CFXJS_Engine::InitializeEngine() { v8::Local<v8::Object> obj = NewFxDynamicObj(i, true); if (!obj.IsEmpty()) { v8Context->Global()->Set(v8Context, pObjName, obj).FromJust(); - m_StaticObjects[i] = new v8::Global<v8::Object>(GetIsolate(), obj); - } else { - m_StaticObjects[i] = nullptr; + m_StaticObjects[i] = v8::Global<v8::Object>(GetIsolate(), obj); } } } @@ -444,10 +442,9 @@ void CFXJS_Engine::ReleaseEngine() { if (pObjDef->m_ObjType == FXJSOBJTYPE_GLOBAL) { pObj = context->Global()->GetPrototype()->ToObject(context).ToLocalChecked(); - } else if (m_StaticObjects[i] && !m_StaticObjects[i]->IsEmpty()) { - pObj = v8::Local<v8::Object>::New(GetIsolate(), *m_StaticObjects[i]); - delete m_StaticObjects[i]; - m_StaticObjects[i] = nullptr; + } else if (!m_StaticObjects[i].IsEmpty()) { + pObj = v8::Local<v8::Object>::New(GetIsolate(), m_StaticObjects[i]); + m_StaticObjects[i].Reset(); } if (!pObj.IsEmpty()) { |