summaryrefslogtreecommitdiffstats
path: root/basic
diff options
context:
space:
mode:
authorArnaud Versini <arnaud.versini@gmail.com>2016-03-13 18:25:00 +0100
committerArnaud Versini <arnaud.versini@libreoffice.org>2016-03-20 12:56:04 +0000
commitbb3930bb91c776e6853ee7bcd4db26b1bcc47348 (patch)
treeea5f1b82c7d108565fadef80d76f4727d8db20b3 /basic
parenttdf#90834: Drop an 'in-line change log' style comment (diff)
downloadcore-bb3930bb91c776e6853ee7bcd4db26b1bcc47348.tar.gz
core-bb3930bb91c776e6853ee7bcd4db26b1bcc47348.zip
BASIC : Use std::vector in SbiRuntime to save references
Change-Id: Ica819538b39e58416825e651d057620a66f731cd Reviewed-on: https://gerrit.libreoffice.org/23193 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Arnaud Versini <arnaud.versini@libreoffice.org>
Diffstat (limited to 'basic')
-rw-r--r--basic/source/inc/runtime.hxx35
-rw-r--r--basic/source/runtime/runtime.cxx17
2 files changed, 4 insertions, 48 deletions
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<SbxVariableRef> 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<SbxVariable*>(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!