From 56286b311543331d02fee90b832d66389a307961 Mon Sep 17 00:00:00 2001 From: tsepez Date: Tue, 17 May 2016 16:24:34 -0700 Subject: Remove some CFX_ArrayTemplate<> usage from fxjse Allows use of otherwise incompatible unique_ptrs. Review-Url: https://codereview.chromium.org/1992513002 --- xfa/fxjse/runtime.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'xfa/fxjse/runtime.cpp') diff --git a/xfa/fxjse/runtime.cpp b/xfa/fxjse/runtime.cpp index 7b62174899..1ee6c18599 100644 --- a/xfa/fxjse/runtime.cpp +++ b/xfa/fxjse/runtime.cpp @@ -6,6 +6,8 @@ #include "xfa/fxjse/runtime.h" +#include + #include "fpdfsdk/jsapi/include/fxjs_v8.h" #include "xfa/fxjse/scope_inline.h" @@ -99,30 +101,27 @@ CFXJSE_RuntimeData* CFXJSE_RuntimeData::Get(v8::Isolate* pIsolate) { return pData->m_pFXJSERuntimeData; } -CFXJSE_RuntimeList* CFXJSE_RuntimeData::g_RuntimeList = NULL; +CFXJSE_RuntimeList* CFXJSE_RuntimeData::g_RuntimeList = nullptr; + void CFXJSE_RuntimeList::AppendRuntime(v8::Isolate* pIsolate) { - m_RuntimeList.Add(pIsolate); + m_RuntimeList.push_back(pIsolate); } void CFXJSE_RuntimeList::RemoveRuntime( v8::Isolate* pIsolate, CFXJSE_RuntimeList::RuntimeDisposeCallback lpfnDisposeCallback) { - int32_t iIdx = m_RuntimeList.Find(pIsolate, 0); - if (iIdx >= 0) { - m_RuntimeList.RemoveAt(iIdx, 1); - } - if (lpfnDisposeCallback) { + auto it = std::find(m_RuntimeList.begin(), m_RuntimeList.end(), pIsolate); + if (it != m_RuntimeList.end()) + m_RuntimeList.erase(it); + if (lpfnDisposeCallback) lpfnDisposeCallback(pIsolate); - } } void CFXJSE_RuntimeList::RemoveAllRuntimes( CFXJSE_RuntimeList::RuntimeDisposeCallback lpfnDisposeCallback) { - int32_t iSize = m_RuntimeList.GetSize(); if (lpfnDisposeCallback) { - for (int32_t iIdx = 0; iIdx < iSize; iIdx++) { - lpfnDisposeCallback(m_RuntimeList[iIdx]); - } + for (v8::Isolate* pIsolate : m_RuntimeList) + lpfnDisposeCallback(pIsolate); } - m_RuntimeList.RemoveAll(); + m_RuntimeList.clear(); } -- cgit v1.2.3