From bb3930bb91c776e6853ee7bcd4db26b1bcc47348 Mon Sep 17 00:00:00 2001 From: Arnaud Versini Date: Sun, 13 Mar 2016 18:25:00 +0100 Subject: BASIC : Use std::vector in SbiRuntime to save references Change-Id: Ica819538b39e58416825e651d057620a66f731cd Reviewed-on: https://gerrit.libreoffice.org/23193 Tested-by: Jenkins Reviewed-by: Arnaud Versini --- basic/source/inc/runtime.hxx | 35 +---------------------------------- basic/source/runtime/runtime.cxx | 17 +++-------------- 2 files changed, 4 insertions(+), 48 deletions(-) (limited to 'basic') diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx index 94e2aeb72943..b7374eaa5f99 100644 --- a/basic/source/inc/runtime.hxx +++ b/basic/source/inc/runtime.hxx @@ -210,16 +210,6 @@ public: LanguageType* peFormatterLangType=nullptr, DateFormat* peFormatterDateFormat=nullptr ); }; -// chainable items to keep references temporary -struct RefSaveItem -{ - SbxVariableRef xRef; - RefSaveItem* pNext; - - RefSaveItem() { pNext = nullptr; } -}; - - // There's one instance of this class for every executed sub-program. // This instance is the heart of the BASIC-machine and contains only local data. @@ -274,30 +264,7 @@ class SbiRuntime sal_uInt16 nOps; // opcode counter sal_uInt32 m_nLastTime; - RefSaveItem* pRefSaveList; // #74254 save temporary references - RefSaveItem* pItemStoreList; // keep unused items - void SaveRef( SbxVariable* pVar ) - { - RefSaveItem* pItem = pItemStoreList; - if( pItem ) - pItemStoreList = pItem->pNext; - else - pItem = new RefSaveItem(); - pItem->pNext = pRefSaveList; - pItem->xRef = pVar; - pRefSaveList = pItem; - } - void ClearRefs() - { - while( pRefSaveList ) - { - RefSaveItem* pToClearItem = pRefSaveList; - pRefSaveList = pToClearItem->pNext; - pToClearItem->xRef = nullptr; - pToClearItem->pNext = pItemStoreList; - pItemStoreList = pToClearItem; - } - } + std::vector aRefSaved; // #74254 save temporary references SbxVariable* FindElement ( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt32 nOp2, SbError, bool bLocal, bool bStatic = false ); diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 239d707e1b60..881c161db543 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -593,8 +593,6 @@ SbiRuntime::SbiRuntime( SbModule* pm, SbMethod* pe, sal_uInt32 nStart ) refExprStk = new SbxArray; SetVBAEnabled( pMod->IsVBACompat() ); SetParameters( pe ? pe->GetParameters() : nullptr ); - pRefSaveList = nullptr; - pItemStoreList = nullptr; } SbiRuntime::~SbiRuntime() @@ -602,15 +600,6 @@ SbiRuntime::~SbiRuntime() ClearGosubStack(); ClearArgvStack(); ClearForStack(); - - // #74254 free items for saving temporary references - ClearRefs(); - while( pItemStoreList ) - { - RefSaveItem* pToDeleteItem = pItemStoreList; - pItemStoreList = pToDeleteItem->pNext; - delete pToDeleteItem; - } } void SbiRuntime::SetVBAEnabled(bool bEnabled ) @@ -4038,7 +4027,7 @@ void SbiRuntime::StepELEM( sal_uInt32 nOp1, sal_uInt32 nOp2 ) // #74254 now per list if( pObj ) { - SaveRef( static_cast(pObj) ); + aRefSaved.push_back( pObj ); } PushVar( FindElement( pObj, nOp1, nOp2, ERRCODE_BASIC_NO_METHOD, false ) ); } @@ -4118,7 +4107,7 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 ) else if( t != SbxVARIANT && (SbxDataType)(p->GetType() & 0x0FFF ) != t ) { SbxVariable* q = new SbxVariable( t ); - SaveRef( q ); + aRefSaved.push_back( q ); *q = *p; p = q; if ( i ) @@ -4212,7 +4201,7 @@ void SbiRuntime::StepSTMNT( sal_uInt32 nOp1, sal_uInt32 nOp2 ) ClearExprStack(); - ClearRefs(); + aRefSaved.clear(); // We have to cancel hard here because line and column // would be wrong later otherwise! -- cgit