[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - basctl/source

Noel Power noel.power at suse.com
Fri Jun 28 02:25:53 PDT 2013


 basctl/source/basicide/basobj2.cxx |   41 ++++++++++++++++++++++++++++---------
 1 file changed, 32 insertions(+), 9 deletions(-)

New commits:
commit 2d7dff2d677475c7e29e5340d0ebef8545aefd97
Author: Noel Power <noel.power at suse.com>
Date:   Thu Jun 27 13:58:48 2013 +0100

    improve performance switching modules in large Libraries fdo#66148
    
    object catalog when updated, updates ( all ) entries and was parsing
    the source for every method in every module
    
    Change-Id: Id68e3c24d597d29a86d3507a7dc20745c96dd2a2
    (cherry picked from commit 61027ca6eb450fb20bfe9209ba180fe0606baeab)
    Reviewed-on: https://gerrit.libreoffice.org/4598
    Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
    Tested-by: Fridrich Strba <fridrich at documentfoundation.org>

diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx
index 7e62558..d5e4b91 100644
--- a/basctl/source/basicide/basobj2.cxx
+++ b/basctl/source/basicide/basobj2.cxx
@@ -42,7 +42,7 @@
 #include <vector>
 #include <algorithm>
 #include <memory>
-
+#include "basic/basmgr.hxx"
 namespace basctl
 {
 
@@ -405,13 +405,25 @@ Sequence< OUString > GetMethodNames( const ScriptDocument& rDocument, const OUSt
     OUString aOUSource;
     if ( rDocument.getModule( rLibName, rModName, aOUSource ) )
     {
-        SbModuleRef xModule = new SbModule( rModName );
-        xModule->SetSource32( aOUSource );
-        sal_uInt16 nCount = xModule->GetMethods()->Count();
+        BasicManager* pBasMgr = rDocument.getBasicManager();
+        StarBASIC* pSb = pBasMgr ? pBasMgr->GetLib( rLibName ) : NULL;
+        SbModule* pMod = pSb ? pSb->FindModule( rModName ) : NULL;
+
+        SbModuleRef xModule;
+        // Only reparse modules if ScriptDocument source is out of sync
+        // with basic's Module
+        if ( !pMod || ( pMod && pMod->GetSource() != aOUSource ) )
+        {
+            xModule = new SbModule( rModName );
+            xModule->SetSource32( aOUSource );
+            pMod = xModule;
+        }
+
+        sal_uInt16 nCount = pMod->GetMethods()->Count();
         sal_uInt16 nRealCount = nCount;
         for ( sal_uInt16 i = 0; i < nCount; i++ )
         {
-            SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( i );
+            SbMethod* pMethod = (SbMethod*)pMod->GetMethods()->Get( i );
             if( pMethod->IsHidden() )
                 --nRealCount;
         }
@@ -420,7 +432,7 @@ Sequence< OUString > GetMethodNames( const ScriptDocument& rDocument, const OUSt
         sal_uInt16 iTarget = 0;
         for ( sal_uInt16 i = 0 ; i < nCount; ++i )
         {
-            SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( i );
+            SbMethod* pMethod = (SbMethod*)pMod->GetMethods()->Get( i );
             if( pMethod->IsHidden() )
                 continue;
             SAL_WARN_IF( !pMethod, "basctl.basicide","Method not found! (NULL)" );
@@ -445,9 +457,20 @@ bool HasMethod (
     OUString aOUSource;
     if ( rDocument.hasModule( rLibName, rModName ) && rDocument.getModule( rLibName, rModName, aOUSource ) )
     {
-        SbModuleRef xModule = new SbModule( rModName );
-        xModule->SetSource32( aOUSource );
-        SbxArray* pMethods = xModule->GetMethods();
+        // Check if we really need to scan the source ( again )
+        BasicManager* pBasMgr = rDocument.getBasicManager();
+        StarBASIC* pSb = pBasMgr ? pBasMgr->GetLib( rLibName ) : NULL;
+        SbModule* pMod = pSb ? pSb->FindModule( rModName ) : NULL;
+        SbModuleRef xModule;
+        // Only reparse modules if ScriptDocument source is out of sync
+        // with basic's Module
+        if ( !pMod || ( pMod && pMod->GetSource() != aOUSource ))
+        {
+            xModule = new SbModule( rModName );
+            xModule->SetSource32( aOUSource );
+            pMod = xModule;
+        }
+        SbxArray* pMethods = pMod->GetMethods();
         if ( pMethods )
         {
             SbMethod* pMethod = (SbMethod*)pMethods->Find( rMethName, SbxCLASS_METHOD );


More information about the Libreoffice-commits mailing list