package/source/xstor/owriteablestream.cxx | 44 +++++++++++++++--------------- svl/source/numbers/zforfind.cxx | 13 ++------ svl/source/numbers/zforfind.hxx | 5 ++- 3 files changed, 28 insertions(+), 34 deletions(-)
New commits: commit e0e310bd80317ac5c63f90976e26d8ee1118c752 Author: Noel Grandin <[email protected]> AuthorDate: Tue Feb 28 09:50:37 2023 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Tue Feb 28 10:54:02 2023 +0000 no need to allocate OTypeCollection separately in WSInternalData_Impl it is only one pointer big Change-Id: I291b1c0aaba2f46aebabefa0341a9e24cf20eeff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147947 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx index 5da3f2199470..56971fbd37d8 100644 --- a/package/source/xstor/owriteablestream.cxx +++ b/package/source/xstor/owriteablestream.cxx @@ -68,7 +68,7 @@ using namespace ::com::sun::star; struct WSInternalData_Impl { rtl::Reference<comphelper::RefCountedMutex> m_xSharedMutex; - ::std::unique_ptr< ::cppu::OTypeCollection> m_pTypeCollection; + ::std::optional< ::cppu::OTypeCollection> m_oTypeCollection; comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenersContainer; // list of listeners sal_Int32 m_nStorageType; @@ -1776,11 +1776,11 @@ void SAL_CALL OWriteStream::release() noexcept uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes() { - if (! m_pData->m_pTypeCollection) + if (! m_pData->m_oTypeCollection) { ::osl::MutexGuard aGuard( m_pData->m_xSharedMutex->GetMutex() ); - if (! m_pData->m_pTypeCollection) + if (! m_pData->m_oTypeCollection) { if ( m_bTransacted ) { @@ -1800,14 +1800,14 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes() , cppu::UnoType<embed::XTransactedObject>::get() , cppu::UnoType<embed::XTransactionBroadcaster>::get()); - m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection - ( cppu::UnoType<beans::XPropertySet>::get() - , aTmpCollection.getTypes())); + m_pData->m_oTypeCollection.emplace( + cppu::UnoType<beans::XPropertySet>::get() + , aTmpCollection.getTypes()); } else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML ) { - m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection - ( cppu::UnoType<lang::XTypeProvider>::get() + m_pData->m_oTypeCollection.emplace( + cppu::UnoType<lang::XTypeProvider>::get() , cppu::UnoType<io::XInputStream>::get() , cppu::UnoType<io::XOutputStream>::get() , cppu::UnoType<io::XStream>::get() @@ -1818,12 +1818,12 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes() , cppu::UnoType<embed::XExtendedStorageStream>::get() , cppu::UnoType<embed::XTransactedObject>::get() , cppu::UnoType<embed::XTransactionBroadcaster>::get() - , cppu::UnoType<beans::XPropertySet>::get())); + , cppu::UnoType<beans::XPropertySet>::get()); } else // if ( m_pData->m_nStorageType == embed::StorageFormats::ZIP ) { - m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection - ( cppu::UnoType<lang::XTypeProvider>::get() + m_pData->m_oTypeCollection.emplace( + cppu::UnoType<lang::XTypeProvider>::get() , cppu::UnoType<io::XInputStream>::get() , cppu::UnoType<io::XOutputStream>::get() , cppu::UnoType<io::XStream>::get() @@ -1833,15 +1833,15 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes() , cppu::UnoType<embed::XExtendedStorageStream>::get() , cppu::UnoType<embed::XTransactedObject>::get() , cppu::UnoType<embed::XTransactionBroadcaster>::get() - , cppu::UnoType<beans::XPropertySet>::get())); + , cppu::UnoType<beans::XPropertySet>::get()); } } else { if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE ) { - m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection - ( cppu::UnoType<lang::XTypeProvider>::get() + m_pData->m_oTypeCollection.emplace( + cppu::UnoType<lang::XTypeProvider>::get() , cppu::UnoType<io::XInputStream>::get() , cppu::UnoType<io::XOutputStream>::get() , cppu::UnoType<io::XStream>::get() @@ -1850,12 +1850,12 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes() , cppu::UnoType<lang::XComponent>::get() , cppu::UnoType<embed::XEncryptionProtectedSource2>::get() , cppu::UnoType<embed::XEncryptionProtectedSource>::get() - , cppu::UnoType<beans::XPropertySet>::get())); + , cppu::UnoType<beans::XPropertySet>::get()); } else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML ) { - m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection - ( cppu::UnoType<lang::XTypeProvider>::get() + m_pData->m_oTypeCollection.emplace( + cppu::UnoType<lang::XTypeProvider>::get() , cppu::UnoType<io::XInputStream>::get() , cppu::UnoType<io::XOutputStream>::get() , cppu::UnoType<io::XStream>::get() @@ -1863,25 +1863,25 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes() , cppu::UnoType<io::XTruncate>::get() , cppu::UnoType<lang::XComponent>::get() , cppu::UnoType<embed::XRelationshipAccess>::get() - , cppu::UnoType<beans::XPropertySet>::get())); + , cppu::UnoType<beans::XPropertySet>::get()); } else // if ( m_pData->m_nStorageType == embed::StorageFormats::ZIP ) { - m_pData->m_pTypeCollection.reset(new ::cppu::OTypeCollection - ( cppu::UnoType<lang::XTypeProvider>::get() + m_pData->m_oTypeCollection.emplace( + cppu::UnoType<lang::XTypeProvider>::get() , cppu::UnoType<io::XInputStream>::get() , cppu::UnoType<io::XOutputStream>::get() , cppu::UnoType<io::XStream>::get() , cppu::UnoType<io::XSeekable>::get() , cppu::UnoType<io::XTruncate>::get() , cppu::UnoType<lang::XComponent>::get() - , cppu::UnoType<beans::XPropertySet>::get())); + , cppu::UnoType<beans::XPropertySet>::get()); } } } } - return m_pData->m_pTypeCollection->getTypes() ; + return m_pData->m_oTypeCollection->getTypes() ; } uno::Sequence< sal_Int8 > SAL_CALL OWriteStream::getImplementationId() commit 94b18584e1332bc4bb529fc3a7d13ab5ce15f8fb Author: Noel Grandin <[email protected]> AuthorDate: Tue Feb 28 09:49:17 2023 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Tue Feb 28 10:53:55 2023 +0000 no need to allocate Date separately in ImpSvNumberInputScan it is only one pointer big Change-Id: I8b0b7ea0cf69cecabc2ddfb7e5d134037221057c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147946 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index 029b2b556d0f..de5aacf69d2b 100644 --- a/svl/source/numbers/zforfind.cxx +++ b/svl/source/numbers/zforfind.cxx @@ -81,7 +81,7 @@ ImpSvNumberInputScan::ImpSvNumberInputScan( SvNumberFormatter* pFormatterP ) eSetType( SvNumFormatType::UNDEFINED ) { pFormatter = pFormatterP; - pNullDate.reset( new Date(30,12,1899) ); + moNullDate.emplace( 30,12,1899 ); nYear2000 = SvNumberFormatter::GetYear2000Default(); Reset(); ChangeIntl(); @@ -2262,7 +2262,7 @@ input for the following reasons: if ( res && pCal->isValid() ) { - double fDiff = DateTime(*pNullDate) - pCal->getEpochStart(); + double fDiff = DateTime(*moNullDate) - pCal->getEpochStart(); fDays = ::rtl::math::approxFloor( pCal->getLocalDateTime() ); fDays -= fDiff; nTryOrder = nFormatOrder; // break for @@ -3831,14 +3831,7 @@ void ImpSvNumberInputScan::ChangeNullDate( const sal_uInt16 Day, const sal_uInt16 Month, const sal_Int16 Year ) { - if ( pNullDate ) - { - *pNullDate = Date(Day, Month, Year); - } - else - { - pNullDate.reset(new Date(Day, Month, Year)); - } + moNullDate = Date(Day, Month, Year); } diff --git a/svl/source/numbers/zforfind.hxx b/svl/source/numbers/zforfind.hxx index 5696b6ca21a3..dea732b93297 100644 --- a/svl/source/numbers/zforfind.hxx +++ b/svl/source/numbers/zforfind.hxx @@ -23,9 +23,10 @@ #include <com/sun/star/uno/Sequence.hxx> #include <rtl/ustring.hxx> #include <svl/zforlist.hxx> +#include <tools/date.hxx> #include <memory> +#include <optional> -class Date; class SvNumberformat; class SvNumberFormatter; enum class SvNumFormatType : sal_Int16; @@ -89,7 +90,7 @@ private: bool bTextInitialized; //* Whether days and months are initialized bool bScanGenitiveMonths; //* Whether to scan an input for genitive months bool bScanPartitiveMonths; //* Whether to scan an input for partitive months - std::unique_ptr<Date> pNullDate; //* 30Dec1899 + std::optional<Date> moNullDate; //* 30Dec1899 // Variables for provisional results: OUString sStrArray[SV_MAX_COUNT_INPUT_STRINGS];//* Array of scanned substrings bool IsNum[SV_MAX_COUNT_INPUT_STRINGS]; //* Whether a substring is numeric
