[Libreoffice-commits] .: xmloff/inc xmloff/source

Stephan Bergmann sbergmann at kemper.freedesktop.org
Tue Jan 31 02:34:19 PST 2012


 xmloff/inc/xmloff/nmspmap.hxx  |   24 ++++++++++--------------
 xmloff/source/core/nmspmap.cxx |   23 +++++++++--------------
 2 files changed, 19 insertions(+), 28 deletions(-)

New commits:
commit 965f3ae45ad605baf4d25d3cc8aaa9be85886b97
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Jan 31 11:32:02 2012 +0100

    Clean up

diff --git a/xmloff/inc/xmloff/nmspmap.hxx b/xmloff/inc/xmloff/nmspmap.hxx
index 79139ef..816f2d3 100644
--- a/xmloff/inc/xmloff/nmspmap.hxx
+++ b/xmloff/inc/xmloff/nmspmap.hxx
@@ -30,11 +30,14 @@
 #define _XMLOFF_NMSPMAP_HXX
 
 #include "sal/config.h"
+
+#include <map>
+#include <utility>
+
 #include "xmloff/dllapi.h"
 #include "sal/types.h"
 #include <rtl/ustring.hxx>
 #include <boost/unordered_map.hpp>
-#include <map>
 #include <rtl/ref.hxx>
 #include <cppuhelper/weak.hxx>
 
@@ -73,25 +76,17 @@ struct uInt32lt
         return r1 < r2;
     }
 };
-typedef ::std::pair < sal_uInt16, const ::rtl::OUString* > QNamePair;
+typedef ::std::pair < sal_uInt16, rtl::OUString > QNamePair;
 
 struct QNamePairHash
 {
     size_t operator()( const QNamePair &r1 ) const
     {
-        return (size_t) r1.second->hashCode() + r1.first;
-    }
-};
-struct QNamePairEq
-{
-    bool operator()( const QNamePair &r1,
-                     const QNamePair &r2 ) const
-    {
-        return r1.first == r2.first && *(r1.second) == *(r2.second);
+        return (size_t) r1.second.hashCode() + r1.first;
     }
 };
 
-typedef ::boost::unordered_map < QNamePair, ::rtl::OUString, QNamePairHash, QNamePairEq > QNameCache;
+typedef ::boost::unordered_map < QNamePair, ::rtl::OUString, QNamePairHash > QNameCache;
 typedef ::boost::unordered_map < ::rtl::OUString, ::rtl::Reference <NameSpaceEntry >, rtl::OUStringHash, OUStringEqFunc > NameSpaceHash;
 typedef ::std::map < sal_uInt16, ::rtl::Reference < NameSpaceEntry >, uInt32lt > NameSpaceMap;
 
@@ -100,9 +95,10 @@ class XMLOFF_DLLPUBLIC SvXMLNamespaceMap
     const ::rtl::OUString       sXMLNS;
     const ::rtl::OUString       sEmpty;
 
-    NameSpaceHash               aNameHash, aNameCache;
+    NameSpaceHash               aNameHash;
+    mutable NameSpaceHash       aNameCache;
     NameSpaceMap                aNameMap;
-    QNameCache                  aQNameCache;
+    mutable QNameCache          aQNameCache;
     SAL_DLLPRIVATE sal_uInt16 _Add( const rtl::OUString& rPrefix, const rtl::OUString &rName, sal_uInt16 nKey );
 
 public:
diff --git a/xmloff/source/core/nmspmap.cxx b/xmloff/source/core/nmspmap.cxx
index 383df82..06e6caa 100644
--- a/xmloff/source/core/nmspmap.cxx
+++ b/xmloff/source/core/nmspmap.cxx
@@ -26,6 +26,8 @@
  *
  ************************************************************************/
 
+#include "sal/config.h"
+
 #include <tools/debug.hxx>
 #include <rtl/ustring.hxx>
 #include <rtl/ustrbuf.hxx>
@@ -75,13 +77,6 @@ void SvXMLNamespaceMap::operator=( const SvXMLNamespaceMap& rMap )
 
 SvXMLNamespaceMap::~SvXMLNamespaceMap()
 {
-    QNameCache::iterator aIter = aQNameCache.begin(), aEnd = aQNameCache.end();
-    while ( aIter != aEnd )
-    {
-        const OUString *pString = (*aIter).first.second;
-        ++aIter;
-        delete pString;
-    }
 }
 
 int SvXMLNamespaceMap::operator ==( const SvXMLNamespaceMap& rCmp ) const
@@ -243,7 +238,7 @@ OUString SvXMLNamespaceMap::GetQNameByKey( sal_uInt16 nKey,
         {
             QNameCache::const_iterator aQCacheIter;
             if (bCache)
-                aQCacheIter = aQNameCache.find ( QNamePair ( nKey, &rLocalName ) );
+                aQCacheIter = aQNameCache.find ( QNamePair ( nKey, rLocalName ) );
             else
                 aQCacheIter = aQNameCache.end();
             if ( aQCacheIter != aQNameCache.end() )
@@ -265,8 +260,9 @@ OUString SvXMLNamespaceMap::GetQNameByKey( sal_uInt16 nKey,
                     if (bCache)
                     {
                         OUString sString(sQName.makeStringAndClear());
-                        OUString *pString = new OUString ( rLocalName );
-                        const_cast < QNameCache * > (&aQNameCache)->operator[] ( QNamePair ( nKey, pString ) ) = sString;
+                        aQNameCache.insert(
+                            QNameCache::value_type(
+                                QNamePair(nKey, rLocalName), sString));
                         return sString;
                     }
                     else
@@ -357,10 +353,9 @@ sal_uInt16 SvXMLNamespaceMap::_GetKeyByAttrName( const OUString& rAttrName,
             nKey = xEntry->nKey = XML_NAMESPACE_NONE;
 
         if (bCache)
-    {
-        typedef std::pair< const rtl::OUString, rtl::Reference<NameSpaceEntry> > value_type;
-        (void) const_cast<NameSpaceHash*>(&aNameCache)->insert (value_type (rAttrName, xEntry));
-    }
+        {
+            aNameCache.insert(NameSpaceHash::value_type(rAttrName, xEntry));
+        }
     }
 
     return nKey;


More information about the Libreoffice-commits mailing list