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

Stephan Bergmann sbergman at redhat.com
Fri Dec 13 07:19:17 PST 2013


 cppuhelper/source/shlib.cxx |   72 +++++++++++++++++++++++++-------------------
 1 file changed, 41 insertions(+), 31 deletions(-)

New commits:
commit a4ed79bbf615fec10b39f46a5828ffea04d84f4e
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Dec 13 16:18:52 2013 +0100

    Shortcut common case of calling same-env component_getFactory fn
    
    Change-Id: I7f5d31c3b3e128b2df4d83c915673bf7b5d2ab8c

diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx
index 8ad77f5..ecb3f1f 100644
--- a/cppuhelper/source/shlib.cxx
+++ b/cppuhelper/source/shlib.cxx
@@ -188,47 +188,57 @@ Reference< XInterface > invokeComponentFactory(
             fprintf(stderr, "invokeComponentFactory envDcp:%s implName:%s modPath:%s\n", envDcp.getStr(), implName.getStr(), modPath.getStr());
         }
 #endif
-
-        Mapping aCurrent2Env( currentEnv, env );
-        Mapping aEnv2Current( env, currentEnv );
-
-        if (aCurrent2Env.is() && aEnv2Current.is())
+        if (env.get() == currentEnv.get())
         {
-            void * pSMgr = aCurrent2Env.mapInterface(
-                xMgr.get(), ::getCppuType( &xMgr ) );
+            xRet.set(
+                static_cast<css::uno::XInterface *>(
+                    (*reinterpret_cast<component_getFactoryFunc>(pGetter))(
+                        aImplName.getStr(), xMgr.get(), 0)),
+                SAL_NO_ACQUIRE);
+        }
+        else
+        {
+            Mapping aCurrent2Env( currentEnv, env );
+            Mapping aEnv2Current( env, currentEnv );
 
-            void * pSSF = NULL;
+            if (aCurrent2Env.is() && aEnv2Current.is())
+            {
+                void * pSMgr = aCurrent2Env.mapInterface(
+                    xMgr.get(), ::getCppuType( &xMgr ) );
 
-            env.invoke(s_getFactory, pGetter, &aImplName, pSMgr, 0, &pSSF);
+                void * pSSF = NULL;
 
-            if (pSMgr)
-            {
-                (*env.get()->pExtEnv->releaseInterface)(
-                    env.get()->pExtEnv, pSMgr );
-            }
+                env.invoke(s_getFactory, pGetter, &aImplName, pSMgr, 0, &pSSF);
 
-            if (pSSF)
-            {
-                aEnv2Current.mapInterface(
-                    reinterpret_cast< void ** >( &xRet ),
-                    pSSF, ::getCppuType( &xRet ) );
-                (env.get()->pExtEnv->releaseInterface)(
-                    env.get()->pExtEnv, pSSF );
+                if (pSMgr)
+                {
+                    (*env.get()->pExtEnv->releaseInterface)(
+                        env.get()->pExtEnv, pSMgr );
+                }
+
+                if (pSSF)
+                {
+                    aEnv2Current.mapInterface(
+                        reinterpret_cast< void ** >( &xRet ),
+                        pSSF, ::getCppuType( &xRet ) );
+                    (env.get()->pExtEnv->releaseInterface)(
+                        env.get()->pExtEnv, pSSF );
+                }
+                else
+                {
+                    rExcMsg = rModulePath +
+                        ": cannot get factory of " +
+                        "demanded implementation: " +
+                        OStringToOUString(
+                            aImplName, RTL_TEXTENCODING_ASCII_US );
+                }
             }
             else
             {
-                rExcMsg = rModulePath +
-                          ": cannot get factory of " +
-                          "demanded implementation: " +
-                          OStringToOUString(
-                        aImplName, RTL_TEXTENCODING_ASCII_US );
+                rExcMsg =
+                    "cannot get uno mappings: C++ <=> UNO!";
             }
         }
-        else
-        {
-            rExcMsg =
-                "cannot get uno mappings: C++ <=> UNO!";
-        }
     }
     else
     {


More information about the Libreoffice-commits mailing list