[Libreoffice-commits] .: 4 commits - berkeleydb/makefile.mk desktop/source framework/source sfx2/source

Caolán McNamara caolan at kemper.freedesktop.org
Fri Mar 23 03:36:46 PDT 2012


 berkeleydb/makefile.mk                     |    4 ++
 desktop/source/deployment/dp_persmap.cxx   |    4 +-
 desktop/source/deployment/inc/db.hxx       |    8 ----
 desktop/source/deployment/misc/db.cxx      |   56 ++++++++++++++++++++++++++---
 framework/source/jobs/jobexecutor.cxx      |   20 +++++-----
 framework/source/services/pathsettings.cxx |   18 ++++-----
 sfx2/source/appl/appbaslib.cxx             |   11 -----
 7 files changed, 79 insertions(+), 42 deletions(-)

New commits:
commit 76876513479522b37c9047a418521624e27afff6
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Mar 23 08:53:25 2012 +0000

    Take a meg off our memory footprint
    
    We create 6 berkleydb backed databases. If no DB_ENV is provided for a
    database, then berkleydb creates one for each database. Each
    environment has a memory footprint of about 200k. It appears to be
    legal to share an environment, which shaves about 1M off our
    permanant footprint.

diff --git a/desktop/source/deployment/misc/db.cxx b/desktop/source/deployment/misc/db.cxx
index 45f91c7..98cfc01 100644
--- a/desktop/source/deployment/misc/db.cxx
+++ b/desktop/source/deployment/misc/db.cxx
@@ -30,6 +30,7 @@
 #include <db.hxx>
 
 #include <rtl/alloc.h>
+#include <rtl/instance.hxx>
 #include <cstring>
 #include <errno.h>
 
@@ -54,12 +55,57 @@ char *DbEnv::strerror(int error)
     return (db_strerror(error));
 }
 
+namespace
+{
+    class theDbEnvMutex
+        : public rtl::Static<osl::Mutex, theDbEnvMutex> {};
+
+    class SharedDbEnv : private boost::noncopyable
+    {
+    public:
+        static DB_ENV* getInstance();
+        static void releaseInstance();
+    private:
+        SharedDbEnv();
+        ~SharedDbEnv();
+        static DB_ENV* pSharedEnv;
+        static int nSharedEnv;
+    };
+
+    DB_ENV* SharedDbEnv::pSharedEnv = NULL;
+    int SharedDbEnv::nSharedEnv = 0;
+
+    DB_ENV* SharedDbEnv::getInstance()
+    {
+        ::osl::MutexGuard aGuard(theDbEnvMutex::get());
+        if (pSharedEnv == NULL)
+        {
+            db_env_create(&pSharedEnv, 0);
+            pSharedEnv->open(pSharedEnv, NULL, DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE | DB_THREAD, 0);
+        }
+        ++nSharedEnv;
+        return pSharedEnv;
+    }
+
+    void SharedDbEnv::releaseInstance()
+    {
+        ::osl::MutexGuard aGuard(theDbEnvMutex::get());
+        --nSharedEnv;
+        if (0 == nSharedEnv)
+        {
+            pSharedEnv->close(pSharedEnv, 0);
+            pSharedEnv = NULL;
+        }
+    }
+}
+
 //----------------------------------------------------------------------------
 
 Db::Db(u_int32_t flags)
     : m_pDBP(0)
 {
-    db_internal::check_error( db_create(&m_pDBP, NULL, flags),"Db::Db" );
+    DB_ENV *pSharedDbEnv = SharedDbEnv::getInstance();
+    db_internal::check_error( db_create(&m_pDBP, pSharedDbEnv, flags),"Db::Db" );
 }
 
 
@@ -78,6 +124,7 @@ int Db::close(u_int32_t flags)
 {
     int error = m_pDBP->close(m_pDBP,flags);
     m_pDBP = 0;
+    SharedDbEnv::releaseInstance();
     return db_internal::check_error(error,"Db::close");
 }
 
commit f0a2c790192130c0ebf6937673552237c33d4b21
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Mar 23 08:49:03 2012 +0000

    DbEnv argument is always NULL

diff --git a/desktop/source/deployment/dp_persmap.cxx b/desktop/source/deployment/dp_persmap.cxx
index ca55e5f..7c505bb 100644
--- a/desktop/source/deployment/dp_persmap.cxx
+++ b/desktop/source/deployment/dp_persmap.cxx
@@ -78,7 +78,7 @@ PersistentMap::~PersistentMap()
 
 //______________________________________________________________________________
 PersistentMap::PersistentMap( OUString const & url )
-    : m_db( 0, 0 )
+    : m_db( 0 )
 {
     try {
         rtl::OUString fileURL = expandUnoRcUrl(url);
@@ -101,7 +101,7 @@ PersistentMap::PersistentMap( OUString const & url )
 
 //______________________________________________________________________________
 PersistentMap::PersistentMap()
-    : m_db( 0, 0 )
+    : m_db( 0 )
 {
     try {
         // xxx todo: DB_THREAD, DB_DBT_MALLOC currently not used
diff --git a/desktop/source/deployment/inc/db.hxx b/desktop/source/deployment/inc/db.hxx
index a2dd27d..f996fbb 100644
--- a/desktop/source/deployment/inc/db.hxx
+++ b/desktop/source/deployment/inc/db.hxx
@@ -47,7 +47,6 @@ extern "C" {
 
 namespace berkeleydbproxy {
 
-    class DbEnv;
     class Dbc;
     class Dbt;
 
@@ -68,11 +67,6 @@ namespace berkeleydbproxy {
 
     class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC DbEnv : boost::noncopyable
     {
-        friend class Db;
-
-    private:
-        DB_ENV* m_pDBENV;
-
     public:
         static char *strerror(int);
     };
@@ -83,7 +77,7 @@ namespace berkeleydbproxy {
         DB* m_pDBP;
 
     public:
-        Db(DbEnv* dbbenv,u_int32_t flags);
+        Db(u_int32_t flags);
         ~Db();
 
         int close(u_int32_t flags);
diff --git a/desktop/source/deployment/misc/db.cxx b/desktop/source/deployment/misc/db.cxx
index 666bbcb..45f91c7 100644
--- a/desktop/source/deployment/misc/db.cxx
+++ b/desktop/source/deployment/misc/db.cxx
@@ -49,16 +49,17 @@ namespace berkeleydbproxy {
 
 //----------------------------------------------------------------------------
 
-char *DbEnv::strerror(int error) {
+char *DbEnv::strerror(int error)
+{
     return (db_strerror(error));
 }
 
 //----------------------------------------------------------------------------
 
-Db::Db(DbEnv* pDbenv,u_int32_t flags)
-: m_pDBP(0)
+Db::Db(u_int32_t flags)
+    : m_pDBP(0)
 {
-    db_internal::check_error( db_create(&m_pDBP,pDbenv ? pDbenv->m_pDBENV:0,flags),"Db::Db" );
+    db_internal::check_error( db_create(&m_pDBP, NULL, flags),"Db::Db" );
 }
 
 
commit 7988f6135bb7b8d5d8f954c770af7c2ec3915802
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Mar 23 07:52:18 2012 +0000

    build db4 with symbols if symbols globally enabled

diff --git a/berkeleydb/makefile.mk b/berkeleydb/makefile.mk
index 07d6503..082170c 100644
--- a/berkeleydb/makefile.mk
+++ b/berkeleydb/makefile.mk
@@ -74,6 +74,10 @@ CXXFLAGS:=
 .IF "$(COM)"=="GCC"
 CFLAGS:=-fno-strict-aliasing $(EXTRA_CFLAGS)
 CXXFLAGS:=-fno-strict-aliasing $(EXTRA_CFLAGS)
+.IF "$(ENABLE_SYMBOLS)"!=""
+CFLAGS+=-g
+CXXFLAGS+=-g
+.ENDIF
 .ENDIF
 
 .IF "$(GUI)"=="UNX"
commit ae7b4576d7df85b41c914c14cc87674428d2ac79
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Mar 22 16:10:07 2012 +0000

    overly static lingering OUStrings

diff --git a/framework/source/jobs/jobexecutor.cxx b/framework/source/jobs/jobexecutor.cxx
index 22e1da1..9fe0b3d 100644
--- a/framework/source/jobs/jobexecutor.cxx
+++ b/framework/source/jobs/jobexecutor.cxx
@@ -223,12 +223,12 @@ void SAL_CALL JobExecutor::trigger( const ::rtl::OUString& sEvent ) throw(css::u
 
 void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent ) throw(css::uno::RuntimeException)
 {
-    static ::rtl::OUString EVENT_ON_NEW             = DECLARE_ASCII("OnNew"             ); // Doc UI  event
-    static ::rtl::OUString EVENT_ON_LOAD            = DECLARE_ASCII("OnLoad"            ); // Doc UI  event
-    static ::rtl::OUString EVENT_ON_CREATE          = DECLARE_ASCII("OnCreate"          ); // Doc API event
-    static ::rtl::OUString EVENT_ON_LOAD_FINISHED   = DECLARE_ASCII("OnLoadFinished"    ); // Doc API event
-    static ::rtl::OUString EVENT_ON_DOCUMENT_OPENED = DECLARE_ASCII("onDocumentOpened"  ); // Job UI  event : OnNew    or OnLoad
-    static ::rtl::OUString EVENT_ON_DOCUMENT_ADDED  = DECLARE_ASCII("onDocumentAdded"   ); // Job API event : OnCreate or OnLoadFinished
+    const char EVENT_ON_NEW[] = "OnNew";                            // Doc UI  event
+    const char EVENT_ON_LOAD[] = "OnLoad";                          // Doc UI  event
+    const char EVENT_ON_CREATE[] = "OnCreate";                      // Doc API event
+    const char EVENT_ON_LOAD_FINISHED[] = "OnLoadFinished";         // Doc API event
+    ::rtl::OUString EVENT_ON_DOCUMENT_OPENED("onDocumentOpened");   // Job UI  event : OnNew    or OnLoad
+    ::rtl::OUString EVENT_ON_DOCUMENT_ADDED("onDocumentAdded");     // Job API event : OnCreate or OnLoadFinished
 
     /* SAFE { */
     ReadGuard aReadLock(m_aLock);
@@ -251,8 +251,8 @@ void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent
 
     // Special feature: If the events "OnNew" or "OnLoad" occures - we generate our own event "onDocumentOpened".
     if (
-        (aEvent.EventName.equals(EVENT_ON_NEW )) ||
-        (aEvent.EventName.equals(EVENT_ON_LOAD))
+        (aEvent.EventName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(EVENT_ON_NEW))) ||
+        (aEvent.EventName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(EVENT_ON_LOAD)))
        )
     {
         if (m_lEvents.find(EVENT_ON_DOCUMENT_OPENED) != m_lEvents.end())
@@ -261,8 +261,8 @@ void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent
 
     // Special feature: If the events "OnCreate" or "OnLoadFinished" occures - we generate our own event "onDocumentAdded".
     if (
-        (aEvent.EventName.equals(EVENT_ON_CREATE       )) ||
-        (aEvent.EventName.equals(EVENT_ON_LOAD_FINISHED))
+        (aEvent.EventName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(EVENT_ON_CREATE))) ||
+        (aEvent.EventName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(EVENT_ON_LOAD_FINISHED)))
        )
     {
         if (m_lEvents.find(EVENT_ON_DOCUMENT_ADDED) != m_lEvents.end())
diff --git a/framework/source/services/pathsettings.cxx b/framework/source/services/pathsettings.cxx
index d70d2b3..9bdd098 100644
--- a/framework/source/services/pathsettings.cxx
+++ b/framework/source/services/pathsettings.cxx
@@ -63,8 +63,8 @@
 // ______________________________________________
 //  non exported const
 
-const ::rtl::OUString CFGPROP_USERPATHS(RTL_CONSTASCII_USTRINGPARAM("UserPaths"));
-const ::rtl::OUString CFGPROP_WRITEPATH(RTL_CONSTASCII_USTRINGPARAM("WritePath"));
+#define CFGPROP_USERPATHS rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UserPaths"))
+#define CFGPROP_WRITEPATH rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WritePath"))
 
 /*
     0 : old style              "Template"              string using ";" as seperator
@@ -73,9 +73,9 @@ const ::rtl::OUString CFGPROP_WRITEPATH(RTL_CONSTASCII_USTRINGPARAM("WritePath")
     3 : write path             "Template_write"        string
  */
 
-const ::rtl::OUString POSTFIX_INTERNAL_PATHS(RTL_CONSTASCII_USTRINGPARAM("_internal"));
-const ::rtl::OUString POSTFIX_USER_PATHS(RTL_CONSTASCII_USTRINGPARAM("_user"));
-const ::rtl::OUString POSTFIX_WRITE_PATH(RTL_CONSTASCII_USTRINGPARAM("_writable"));
+#define POSTFIX_INTERNAL_PATHS rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_internal"))
+#define POSTFIX_USER_PATHS rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_user"))
+#define POSTFIX_WRITE_PATH rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_writable"))
 
 const sal_Int32 IDGROUP_OLDSTYLE        = 0;
 const sal_Int32 IDGROUP_INTERNAL_PATHS = 1;
@@ -270,8 +270,8 @@ OUStringList PathSettings::impl_readOldFormat(const ::rtl::OUString& sPath)
 // NO substitution here ! It's done outside ...
 PathSettings::PathInfo PathSettings::impl_readNewFormat(const ::rtl::OUString& sPath)
 {
-    const static ::rtl::OUString CFGPROP_INTERNALPATHS(RTL_CONSTASCII_USTRINGPARAM("InternalPaths"));
-    const static ::rtl::OUString CFGPROP_ISSINGLEPATH(RTL_CONSTASCII_USTRINGPARAM("IsSinglePath"));
+    const ::rtl::OUString CFGPROP_INTERNALPATHS(RTL_CONSTASCII_USTRINGPARAM("InternalPaths"));
+    const ::rtl::OUString CFGPROP_ISSINGLEPATH(RTL_CONSTASCII_USTRINGPARAM("IsSinglePath"));
 
     css::uno::Reference< css::container::XNameAccess > xCfg = fa_getCfgNew();
 
@@ -1109,7 +1109,7 @@ css::uno::Reference< css::util::XStringSubstitution > PathSettings::fa_getSubsti
 //-----------------------------------------------------------------------------
 css::uno::Reference< css::container::XNameAccess > PathSettings::fa_getCfgOld()
 {
-    const static ::rtl::OUString CFG_NODE_OLD(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Common/Path/Current"));
+    const ::rtl::OUString CFG_NODE_OLD(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Common/Path/Current"));
 
     // SAFE ->
     ReadGuard aReadLock(m_aLock);
@@ -1139,7 +1139,7 @@ css::uno::Reference< css::container::XNameAccess > PathSettings::fa_getCfgOld()
 //-----------------------------------------------------------------------------
 css::uno::Reference< css::container::XNameAccess > PathSettings::fa_getCfgNew()
 {
-    const static ::rtl::OUString CFG_NODE_NEW(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Paths/Paths"));
+    const ::rtl::OUString CFG_NODE_NEW(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Paths/Paths"));
 
     // SAFE ->
     ReadGuard aReadLock(m_aLock);
diff --git a/sfx2/source/appl/appbaslib.cxx b/sfx2/source/appl/appbaslib.cxx
index fcb3728..b50b563 100644
--- a/sfx2/source/appl/appbaslib.cxx
+++ b/sfx2/source/appl/appbaslib.cxx
@@ -183,16 +183,7 @@ Sequence< OUString > SfxApplicationDialogLibraryContainer::impl_getStaticSupport
 
 OUString SfxApplicationDialogLibraryContainer::impl_getStaticImplementationName()
 {
-    static OUString aImplName;
-    static sal_Bool bNeedsInit = sal_True;
-
-    MutexGuard aGuard( Mutex::getGlobalMutex() );
-    if( bNeedsInit )
-    {
-        aImplName = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.sfx2.ApplicationDialogLibraryContainer"));
-        bNeedsInit = sal_False;
-    }
-    return aImplName;
+    return OUString("com.sun.star.comp.sfx2.ApplicationDialogLibraryContainer");
 }
 
 Reference< XInterface > SAL_CALL SfxApplicationDialogLibraryContainer::impl_createInstance


More information about the Libreoffice-commits mailing list