From 94b18584e1332bc4bb529fc3a7d13ab5ce15f8fb Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 28 Feb 2023 09:49:17 +0200 Subject: 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 --- svl/source/numbers/zforfind.cxx | 13 +++---------- svl/source/numbers/zforfind.hxx | 5 +++-- 2 files changed, 6 insertions(+), 12 deletions(-) (limited to 'svl') 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 #include #include +#include #include +#include -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 pNullDate; //* 30Dec1899 + std::optional 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 -- cgit v1.2.3