diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-19 12:27:41 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-20 14:52:04 +0200 |
commit | 6c294343edc283aed0af392c09779fee572c0c4c (patch) | |
tree | 977d2d8c3f6e518d0d1100377cbc470be3742c27 /ucbhelper | |
parent | 15684e5d595289e0a94efd80bbe203ca133845f2 (diff) |
no need to allocate Sequence separately in CommandProcessorInfo
Change-Id: I7f423dbbe9d7251a99397f1293239333fe7b0cee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119216
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucbhelper')
-rw-r--r-- | ucbhelper/source/provider/contentinfo.cxx | 22 | ||||
-rw-r--r-- | ucbhelper/source/provider/contentinfo.hxx | 5 |
2 files changed, 12 insertions, 15 deletions
diff --git a/ucbhelper/source/provider/contentinfo.cxx b/ucbhelper/source/provider/contentinfo.cxx index 394d8d01a8dd..c8f5da5aaa79 100644 --- a/ucbhelper/source/provider/contentinfo.cxx +++ b/ucbhelper/source/provider/contentinfo.cxx @@ -196,10 +196,10 @@ CommandProcessorInfo::~CommandProcessorInfo() uno::Sequence< css::ucb::CommandInfo > SAL_CALL CommandProcessorInfo::getCommands() { - if ( !m_pCommands ) + if ( !m_xCommands ) { osl::MutexGuard aGuard( m_aMutex ); - if ( !m_pCommands ) + if ( !m_xCommands ) { // Get info for commands. @@ -207,9 +207,7 @@ CommandProcessorInfo::getCommands() try { - uno::Sequence< css::ucb::CommandInfo > aCmds - = m_pContent->getCommands( m_xEnv ); - m_pCommands.reset(new uno::Sequence< css::ucb::CommandInfo >( aCmds )); + m_xCommands = m_pContent->getCommands( m_xEnv ); } catch ( uno::RuntimeException const & ) { @@ -217,11 +215,11 @@ CommandProcessorInfo::getCommands() } catch ( uno::Exception const & ) { - m_pCommands.reset(new uno::Sequence< css::ucb::CommandInfo >( 0 )); + m_xCommands.emplace(); } } } - return *m_pCommands; + return *m_xCommands; } @@ -273,7 +271,7 @@ sal_Bool SAL_CALL CommandProcessorInfo::hasCommandByHandle( sal_Int32 Handle ) void CommandProcessorInfo::reset() { osl::MutexGuard aGuard( m_aMutex ); - m_pCommands.reset(); + m_xCommands.reset(); } @@ -286,8 +284,8 @@ bool CommandProcessorInfo::queryCommand( getCommands(); const css::ucb::CommandInfo* pCommands - = m_pCommands->getConstArray(); - sal_Int32 nCount = m_pCommands->getLength(); + = m_xCommands->getConstArray(); + sal_Int32 nCount = m_xCommands->getLength(); for ( sal_Int32 n = 0; n < nCount; ++n ) { const css::ucb::CommandInfo& rCurrCommand = pCommands[ n ]; @@ -310,8 +308,8 @@ bool CommandProcessorInfo::queryCommand( getCommands(); - const css::ucb::CommandInfo* pCommands = m_pCommands->getConstArray(); - sal_Int32 nCount = m_pCommands->getLength(); + const css::ucb::CommandInfo* pCommands = m_xCommands->getConstArray(); + sal_Int32 nCount = m_xCommands->getLength(); for ( sal_Int32 n = 0; n < nCount; ++n ) { const css::ucb::CommandInfo& rCurrCommand = pCommands[ n ]; diff --git a/ucbhelper/source/provider/contentinfo.hxx b/ucbhelper/source/provider/contentinfo.hxx index 09e43c782453..6554c7fcfe66 100644 --- a/ucbhelper/source/provider/contentinfo.hxx +++ b/ucbhelper/source/provider/contentinfo.hxx @@ -20,7 +20,6 @@ #ifndef UCBHELPER_SOURCE_PROVIDER_CONTENTINFO_HXX #define UCBHELPER_SOURCE_PROVIDER_CONTENTINFO_HXX -#include <memory> #include <optional> #include <com/sun/star/ucb/XCommandInfo.hpp> #include <com/sun/star/lang/XTypeProvider.hpp> @@ -89,8 +88,8 @@ class CommandProcessorInfo : { css::uno::Reference< css::ucb::XCommandEnvironment > m_xEnv; - std::unique_ptr<css::uno::Sequence< css::ucb::CommandInfo >> - m_pCommands; + std::optional<css::uno::Sequence< css::ucb::CommandInfo >> + m_xCommands; osl::Mutex m_aMutex; ContentImplHelper* m_pContent; |