[Libreoffice-commits] core.git: basic/source

Arnaud Versini arnaud.versini at gmail.com
Mon Apr 4 19:44:42 UTC 2016


 basic/source/inc/runtime.hxx     |    4 ++--
 basic/source/runtime/runtime.cxx |   26 +++++++++++---------------
 2 files changed, 13 insertions(+), 17 deletions(-)

New commits:
commit c1e4d402c61cc33a67d32b037bda027dadb0964a
Author: Arnaud Versini <arnaud.versini at gmail.com>
Date:   Mon Apr 4 20:04:24 2016 +0200

    BASIC : Use a vector to store the argv stack
    
    Change-Id: I29c93aec598b7f784f549ce05f6b32dfabbfc3ad
    Reviewed-on: https://gerrit.libreoffice.org/23815
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Arnaud Versini <arnaud.versini at libreoffice.org>

diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx
index 6d1a8a0..50dbb5b 100644
--- a/basic/source/inc/runtime.hxx
+++ b/basic/source/inc/runtime.hxx
@@ -40,7 +40,7 @@
 class SbiInstance;                  // active StarBASIC process
 class SbiRuntime;                   // active StarBASIC procedure instance
 
-struct SbiArgvStack;                // Argv stack element
+struct SbiArgv;                     // Argv stack element
 struct SbiGosub;                    // GOSUB stack element
 class  SbiImage;                    // Code-Image
 class  SbiIoSystem;
@@ -230,7 +230,6 @@ class SbiRuntime
     SbxVariableRef   refRedim;   // Array saved to use for REDIM
     SbxVariableRef xDummyVar;       // substitute for variables that weren't found
     SbxVariable* mpExtCaller;       // Caller ( external - e.g. button name, shape, range object etc. - only in vba mode )
-    SbiArgvStack*  pArgvStk;        // ARGV-Stack
     SbiForStack*   pForStk;         // FOR/NEXT-Stack
     sal_uInt16        nExprLvl;         // depth of the expr-stack
     sal_uInt16        nForLvl;          // #118235: Maintain for level
@@ -258,6 +257,7 @@ class SbiRuntime
 
     std::vector<SbxVariableRef>  aRefSaved; // #74254 save temporary references
     std::vector<SbiGosub>   pGosubStk; // GOSUB stack
+    std::vector<SbiArgv>    pArgvStk;  // ARGV-Stack
 
 
     SbxVariable* FindElement
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 80815fe..76a7633 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -111,10 +111,13 @@ bool StarBASIC::isVBAEnabled()
     return false;
 }
 
-struct SbiArgvStack {                   // Argv stack:
-    SbiArgvStack*  pNext;               // Stack Chain
+struct SbiArgv {                   // Argv stack:
     SbxArrayRef    refArgv;             // Argv
     short nArgc;                        // Argc
+
+    SbiArgv(SbxArrayRef refArgv_, short nArgc_) :
+        refArgv(refArgv_),
+        nArgc(nArgc_) {}
 };
 
 #define MAXRECURSION 500 //to prevent dead-recursions
@@ -577,7 +580,6 @@ SbiRuntime::SbiRuntime( SbModule* pm, SbMethod* pe, sal_uInt32 nStart )
 {
     nFlags    = pe ? pe->GetDebugFlags() : 0;
     pIosys    = pInst->GetIoSystem();
-    pArgvStk  = nullptr;
     pForStk   = nullptr;
     pError    = nullptr;
     pErrCode  =
@@ -1080,31 +1082,25 @@ void SbiRuntime::PopGosub()
 
 void SbiRuntime::PushArgv()
 {
-    SbiArgvStack* p = new SbiArgvStack;
-    p->refArgv = refArgv;
-    p->nArgc = nArgc;
+    pArgvStk.emplace_back(refArgv, nArgc);
     nArgc = 1;
     refArgv.Clear();
-    p->pNext = pArgvStk;
-    pArgvStk = p;
 }
 
 void SbiRuntime::PopArgv()
 {
-    if( pArgvStk )
+    if( !pArgvStk.empty() )
     {
-        SbiArgvStack* p = pArgvStk;
-        pArgvStk = p->pNext;
-        refArgv = p->refArgv;
-        nArgc = p->nArgc;
-        delete p;
+        refArgv = pArgvStk.back().refArgv;
+        nArgc = pArgvStk.back().nArgc;
+        pArgvStk.pop_back();
     }
 }
 
 
 void SbiRuntime::ClearArgvStack()
 {
-    while( pArgvStk )
+    while( !pArgvStk.empty() )
     {
         PopArgv();
     }


More information about the Libreoffice-commits mailing list