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 <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2023-02-28 09:49:17 +02:00
parent d6ae28fe07
commit 94b18584e1
2 changed files with 6 additions and 12 deletions

View file

@ -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);
}

View file

@ -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