summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-01-31 11:32:02 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-01-31 11:32:56 +0100
commit965f3ae45ad605baf4d25d3cc8aaa9be85886b97 (patch)
tree3e11dd0f68c259c7bdfbe419b241a01a61c4c82f /xmloff
parent165a5bea14f538ea249ec1567d6c4aa08d5bb174 (diff)
Clean up
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/inc/xmloff/nmspmap.hxx24
-rw-r--r--xmloff/source/core/nmspmap.cxx23
2 files changed, 19 insertions, 28 deletions
diff --git a/xmloff/inc/xmloff/nmspmap.hxx b/xmloff/inc/xmloff/nmspmap.hxx
index 79139ef1223f..816f2d36b1e8 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 383df82b8b62..06e6caa547e9 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;