[Libreoffice-commits] core.git: include/unotools unotools/source

Stephan Bergmann sbergman at redhat.com
Fri Aug 28 00:48:21 PDT 2015


 include/unotools/atom.hxx     |    4 ++--
 unotools/source/misc/atom.cxx |   10 ++++++----
 2 files changed, 8 insertions(+), 6 deletions(-)

New commits:
commit 1b9c3a17e8496aedfb80528c5275e6658154789d
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Aug 28 09:46:57 2015 +0200

    Revert "Simplify MultiAtomProvider::getString"
    
    This reverts commit 625c93a8daa2d23bfd42908e6fbba428d5967e84,
    causes problems in (Linux-only) callers.

diff --git a/include/unotools/atom.hxx b/include/unotools/atom.hxx
index d59f67a..fdc656e 100644
--- a/include/unotools/atom.hxx
+++ b/include/unotools/atom.hxx
@@ -47,7 +47,7 @@ namespace utl {
         ~AtomProvider();
 
         int getAtom( const OUString&, bool bCreate = false );
-        OUString getString( int ) const;
+        const OUString& getString( int ) const;
     };
 
     class UNOTOOLS_DLLPUBLIC MultiAtomProvider
@@ -59,7 +59,7 @@ namespace utl {
 
         int getAtom( int atomClass, const OUString& rString, bool bCreate = false );
 
-        OUString getString( int atomClass, int atom ) const;
+        const OUString& getString( int atomClass, int atom ) const;
     };
 }
 
diff --git a/unotools/source/misc/atom.cxx b/unotools/source/misc/atom.cxx
index 44ad756..85ddad4 100644
--- a/unotools/source/misc/atom.cxx
+++ b/unotools/source/misc/atom.cxx
@@ -45,11 +45,12 @@ int AtomProvider::getAtom( const OUString& rString, bool bCreate )
     return m_nAtoms-1;
 }
 
-OUString AtomProvider::getString( int nAtom ) const
+const OUString& AtomProvider::getString( int nAtom ) const
 {
+    static OUString aEmpty;
     std::unordered_map<int, OUString>::const_iterator it = m_aStringMap.find( nAtom );
 
-    return it == m_aStringMap.end() ? OUString() : it->second;
+    return it == m_aStringMap.end() ? aEmpty : it->second;
 }
 
 MultiAtomProvider::MultiAtomProvider()
@@ -78,14 +79,15 @@ int MultiAtomProvider::getAtom( int atomClass, const OUString& rString, bool bCr
     return INVALID_ATOM;
 }
 
-OUString MultiAtomProvider::getString( int atomClass, int atom ) const
+const OUString& MultiAtomProvider::getString( int atomClass, int atom ) const
 {
     std::unordered_map<int, AtomProvider*>::const_iterator it =
           m_aAtomLists.find( atomClass );
     if( it != m_aAtomLists.end() )
         return it->second->getString( atom );
 
-    return OUString();
+    static OUString aEmpty;
+    return aEmpty;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list