Kaydet (Commit) 3c815c97 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

No need for AcceleratorCache::takeOver...

...as it does the same as the copy assignment op.  And both of those are
apparently already only called with SolarMutex locked, so no need to lock it
again.  So the copy assignment op (as well as the other special memeber
functions) can be left implicitly-declared.  (And some uses of the original
takeOver can be optimized to use move assignment.)

Change-Id: I279a5e3ee85ff2342d6ef5f672108a0712fe116d
Reviewed-on: https://gerrit.libreoffice.org/72831
Tested-by: Jenkins
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst ab8b3172
......@@ -30,29 +30,6 @@
namespace framework
{
AcceleratorCache::AcceleratorCache()
{
}
AcceleratorCache::AcceleratorCache(const AcceleratorCache& rCopy)
{
m_lCommand2Keys = rCopy.m_lCommand2Keys;
m_lKey2Commands = rCopy.m_lKey2Commands;
}
void AcceleratorCache::takeOver(const AcceleratorCache& rCopy)
{
SolarMutexGuard g;
m_lCommand2Keys = rCopy.m_lCommand2Keys;
m_lKey2Commands = rCopy.m_lKey2Commands;
}
AcceleratorCache& AcceleratorCache::operator=(const AcceleratorCache& rCopy)
{
takeOver(rCopy);
return *this;
}
bool AcceleratorCache::hasKey(const css::awt::KeyEvent& aKey) const
{
SolarMutexGuard g;
......
......@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <utility>
#include <accelerators/acceleratorconfiguration.hxx>
#include <accelerators/keymapping.hxx>
#include <accelerators/presethandler.hxx>
......@@ -410,9 +414,9 @@ void XMLBasedAcceleratorConfiguration::impl_ts_save(const css::uno::Reference< c
SolarMutexGuard g;
bChanged = (m_pWriteCache != nullptr);
if (bChanged)
aCache.takeOver(*m_pWriteCache);
aCache = *m_pWriteCache;
else
aCache.takeOver(m_aReadCache);
aCache = m_aReadCache;
xContext = m_xContext;
}
......@@ -438,7 +442,7 @@ void XMLBasedAcceleratorConfiguration::impl_ts_save(const css::uno::Reference< c
// and forget the copy-on-write copied cache
if (bChanged)
{
m_aReadCache.takeOver(*m_pWriteCache);
m_aReadCache = *m_pWriteCache;
m_pWriteCache.reset();
}
}
......@@ -800,9 +804,9 @@ void SAL_CALL XCUBasedAcceleratorConfiguration::storeToStorage(const css::uno::R
SolarMutexGuard g;
if (m_pPrimaryWriteCache != nullptr)
aCache.takeOver(*m_pPrimaryWriteCache);
aCache = *m_pPrimaryWriteCache;
else
aCache.takeOver(m_aPrimaryReadCache);
aCache = m_aPrimaryReadCache;
AcceleratorCache::TKeyList lKeys;
if (m_pSecondaryWriteCache!=nullptr)
......@@ -1055,9 +1059,9 @@ void XCUBasedAcceleratorConfiguration::impl_ts_load( bool bPreferred, const css:
}
if (bPreferred)
m_aPrimaryReadCache.takeOver(aReadCache);
m_aPrimaryReadCache = std::move(aReadCache);
else
m_aSecondaryReadCache.takeOver(aReadCache);
m_aSecondaryReadCache = std::move(aReadCache);
}
void XCUBasedAcceleratorConfiguration::impl_ts_save(bool bPreferred)
......@@ -1093,7 +1097,7 @@ void XCUBasedAcceleratorConfiguration::impl_ts_save(bool bPreferred)
// coverity[check_after_deref] - confusing but correct
if (m_pPrimaryWriteCache)
{
m_aPrimaryReadCache.takeOver(*m_pPrimaryWriteCache);
m_aPrimaryReadCache = *m_pPrimaryWriteCache;
m_pPrimaryWriteCache.reset();
}
}
......@@ -1129,7 +1133,7 @@ void XCUBasedAcceleratorConfiguration::impl_ts_save(bool bPreferred)
// coverity[check_after_deref] - confusing but correct
if (m_pSecondaryWriteCache)
{
m_aSecondaryReadCache.takeOver(*m_pSecondaryWriteCache);
m_aSecondaryReadCache = *m_pSecondaryWriteCache;
m_pSecondaryWriteCache.reset();
}
}
......
......@@ -76,26 +76,6 @@ class AcceleratorCache
// interface
public:
/** @short creates a new - but empty - cache instance. */
AcceleratorCache();
/** @short make a copy of this cache.
@descr Used for the copy-on-write feature.
*/
AcceleratorCache(const AcceleratorCache& rCopy);
/** @short write changes back to the original container.
@param rCopy
the (changed!) copy, which should be written
back to this original container.
*/
void takeOver(const AcceleratorCache& rCopy);
/** TODO document me */
AcceleratorCache& operator=(const AcceleratorCache& rCopy);
/** @short checks if the specified key exists.
@param aKey
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment