diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-19 12:20:04 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-20 09:26:26 +0200 |
commit | 59f2d8be6d43a57049db6ea3e425d49b5a3794e8 (patch) | |
tree | c5cf769386c9fad05cb956f285ede6ce0c3b77ee /ucb | |
parent | 8e6e32ace693f0ca8a1b6fefd81832c4c7e7d5af (diff) |
no need to allocate Sequence separately in DataSupplier_Impl
Change-Id: Ibc66a88472051621262de87458f04b138a76d54f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119213
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/tdoc/tdoc_datasupplier.cxx | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx b/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx index c7bad1e70ffa..6272d9c1420c 100644 --- a/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx +++ b/ucb/source/ucp/tdoc/tdoc_datasupplier.cxx @@ -24,6 +24,7 @@ *************************************************************************/ +#include <optional> #include <vector> #include <com/sun/star/ucb/IllegalIdentifierException.hpp> @@ -66,7 +67,7 @@ struct DataSupplier_Impl std::vector< ResultListEntry > m_aResults; rtl::Reference< Content > m_xContent; uno::Reference< uno::XComponentContext > m_xContext; - std::unique_ptr<uno::Sequence< OUString > > m_pNamesOfChildren; + std::optional<uno::Sequence< OUString > > m_xNamesOfChildren; bool m_bCountFinal; bool m_bThrowException; @@ -207,11 +208,11 @@ bool ResultSetDataSupplier::getResult( sal_uInt32 nIndex ) { for ( sal_uInt32 n = nOldCount; n < sal::static_int_cast<sal_uInt32>( - m_pImpl->m_pNamesOfChildren->getLength()); + m_pImpl->m_xNamesOfChildren->getLength()); ++n ) { const OUString & rName - = m_pImpl->m_pNamesOfChildren->getConstArray()[ n ]; + = m_pImpl->m_xNamesOfChildren->getConstArray()[ n ]; if ( rName.isEmpty() ) { @@ -266,11 +267,11 @@ sal_uInt32 ResultSetDataSupplier::totalCount() { for ( sal_uInt32 n = nOldCount; n < sal::static_int_cast<sal_uInt32>( - m_pImpl->m_pNamesOfChildren->getLength()); + m_pImpl->m_xNamesOfChildren->getLength()); ++n ) { const OUString & rName - = m_pImpl->m_pNamesOfChildren->getConstArray()[ n ]; + = m_pImpl->m_xNamesOfChildren->getConstArray()[ n ]; if ( rName.isEmpty() ) { @@ -369,14 +370,13 @@ bool ResultSetDataSupplier::queryNamesOfChildren() { osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex ); - if ( m_pImpl->m_pNamesOfChildren == nullptr ) + if ( !m_pImpl->m_xNamesOfChildren ) { - std::unique_ptr<uno::Sequence< OUString >> pNamesOfChildren( - new uno::Sequence< OUString >() ); + uno::Sequence< OUString > aNamesOfChildren; if ( !m_pImpl->m_xContent->getContentProvider()->queryNamesOfChildren( m_pImpl->m_xContent->getIdentifier()->getContentIdentifier(), - *pNamesOfChildren ) ) + aNamesOfChildren ) ) { OSL_FAIL( "Got no list of children!" ); m_pImpl->m_bThrowException = true; @@ -384,7 +384,7 @@ bool ResultSetDataSupplier::queryNamesOfChildren() } else { - m_pImpl->m_pNamesOfChildren = std::move( pNamesOfChildren ); + m_pImpl->m_xNamesOfChildren = std::move( aNamesOfChildren ); } } return true; |