summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-05-31 11:11:30 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-05-31 21:36:25 +0200
commitd1dfb7d56137ea62d6f3cdfb07f3ee841eb28f9e (patch)
treed8b5646f204d1ee9fd082db9557425dcbbd3d74e /framework
parent0fa764925185a8a7836967b62ea89b17e60cf45c (diff)
no need to allocate these separately
Change-Id: I9464fbcc1af966755cc4eb8fe0beead4638848ba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116479 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/classes/protocolhandlercache.hxx7
-rw-r--r--framework/source/fwi/classes/protocolhandlercache.cxx24
2 files changed, 16 insertions, 15 deletions
diff --git a/framework/inc/classes/protocolhandlercache.hxx b/framework/inc/classes/protocolhandlercache.hxx
index 78a3449f8aa9..d29ba6795248 100644
--- a/framework/inc/classes/protocolhandlercache.hxx
+++ b/framework/inc/classes/protocolhandlercache.hxx
@@ -20,6 +20,7 @@
#pragma once
#include <unordered_map>
+#include <optional>
#include <com/sun/star/util/URL.hpp>
@@ -90,9 +91,9 @@ class HandlerCache final
private:
/// list of all registered handler registered by her uno implementation names
- static std::unique_ptr<HandlerHash> s_pHandler;
+ static std::optional<HandlerHash> s_pHandler;
/// maps URL pattern to handler names
- static std::unique_ptr<PatternHash> s_pPattern;
+ static std::optional<PatternHash> s_pPattern;
/// informs about config updates
static HandlerCFGAccess* s_pConfig;
/// ref count to construct/destruct internal member lists on demand by using singleton mechanism
@@ -107,7 +108,7 @@ class HandlerCache final
bool search( const OUString& sURL, ProtocolHandler* pReturn ) const;
bool search( const css::util::URL& aURL, ProtocolHandler* pReturn ) const;
- void takeOver(std::unique_ptr<HandlerHash> pHandler, std::unique_ptr<PatternHash> pPattern);
+ void takeOver(HandlerHash aHandler, PatternHash aPattern);
};
/**
diff --git a/framework/source/fwi/classes/protocolhandlercache.cxx b/framework/source/fwi/classes/protocolhandlercache.cxx
index 9288536480d9..1879554c7bed 100644
--- a/framework/source/fwi/classes/protocolhandlercache.cxx
+++ b/framework/source/fwi/classes/protocolhandlercache.cxx
@@ -68,8 +68,8 @@ PatternHash::const_iterator findPatternKey(PatternHash const * hash, const OUStr
That means it use two static member list to hold all necessary information
and a ref count mechanism to create/destroy it on demand.
*/
-std::unique_ptr<HandlerHash> HandlerCache::s_pHandler;
-std::unique_ptr<PatternHash> HandlerCache::s_pPattern;
+std::optional<HandlerHash> HandlerCache::s_pHandler;
+std::optional<PatternHash> HandlerCache::s_pPattern;
sal_Int32 HandlerCache::m_nRefCount = 0;
HandlerCFGAccess* HandlerCache::s_pConfig = nullptr;
@@ -86,8 +86,8 @@ HandlerCache::HandlerCache()
if (m_nRefCount==0)
{
- s_pHandler.reset(new HandlerHash);
- s_pPattern.reset(new PatternHash);
+ s_pHandler.emplace();
+ s_pPattern.emplace();
s_pConfig = new HandlerCFGAccess(PACKAGENAME_PROTOCOLHANDLER);
s_pConfig->read(*s_pHandler, *s_pPattern);
s_pConfig->setCache(this);
@@ -129,7 +129,7 @@ bool HandlerCache::search( const OUString& sURL, ProtocolHandler* pReturn ) cons
SolarMutexGuard aGuard;
- PatternHash::const_iterator pItem = findPatternKey(s_pPattern.get(), sURL);
+ PatternHash::const_iterator pItem = findPatternKey(s_pPattern ? &*s_pPattern : nullptr, sURL);
if (pItem != s_pPattern->end())
{
*pReturn = (*s_pHandler)[pItem->second];
@@ -150,12 +150,12 @@ bool HandlerCache::search( const css::util::URL& aURL, ProtocolHandler* pReturn
return search( aURL.Complete, pReturn );
}
-void HandlerCache::takeOver(std::unique_ptr<HandlerHash> pHandler, std::unique_ptr<PatternHash> pPattern)
+void HandlerCache::takeOver(HandlerHash aHandler, PatternHash aPattern)
{
SolarMutexGuard aGuard;
- s_pHandler = std::move(pHandler);
- s_pPattern = std::move(pPattern);
+ s_pHandler = std::move(aHandler);
+ s_pPattern = std::move(aPattern);
}
/**
@@ -240,12 +240,12 @@ void HandlerCFGAccess::read( HandlerHash& rHandlerHash, PatternHash& rPatternHas
void HandlerCFGAccess::Notify(const css::uno::Sequence< OUString >& /*lPropertyNames*/)
{
- std::unique_ptr<HandlerHash> pHandler(new HandlerHash);
- std::unique_ptr<PatternHash> pPattern(new PatternHash);
+ HandlerHash aHandler;
+ PatternHash aPattern;
- read(*pHandler, *pPattern);
+ read(aHandler, aPattern);
if (m_pCache)
- m_pCache->takeOver(std::move(pHandler), std::move(pPattern));
+ m_pCache->takeOver(std::move(aHandler), std::move(aPattern));
}
void HandlerCFGAccess::ImplCommit()