comphelper/source/misc/date.cxx |    5 ++++-
 tools/source/datetime/tdate.cxx |    5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 8cc4e6c8f572d84dc004d97fa25d17fe85505dc6
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Tue Nov 22 19:04:13 2022 +0100
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Tue Nov 22 20:13:01 2022 +0100

    Calculate null-date days to assert only once
    
    Massively called it is really unnecessary to do that each and
    every time. The debug build is slow enough..
    
    Change-Id: I06525e4ca1fa23a1d49dd735370eb157157800e7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143127
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

diff --git a/comphelper/source/misc/date.cxx b/comphelper/source/misc/date.cxx
index ea8a588dbabd..b14ef501d331 100644
--- a/comphelper/source/misc/date.cxx
+++ b/comphelper/source/misc/date.cxx
@@ -100,7 +100,10 @@ sal_Int32 convertDateToDaysNormalizing(sal_uInt16 nDay, 
sal_uInt16 nMonth, sal_I
     // Speed-up the common null-date 1899-12-30.
     if (nYear == 1899 && nDay == 30 && nMonth == 12)
     {
-        assert(convertDateToDays(nDay, nMonth, nYear) == 693594);
+#ifndef NDEBUG
+        static sal_Int32 nDays = convertDateToDays(nDay, nMonth, nYear);
+        assert(nDays == 693594);
+#endif
         return 693594;
     }
     normalize(nDay, nMonth, nYear);
diff --git a/tools/source/datetime/tdate.cxx b/tools/source/datetime/tdate.cxx
index 4b135fc3008a..e20add430353 100644
--- a/tools/source/datetime/tdate.cxx
+++ b/tools/source/datetime/tdate.cxx
@@ -72,7 +72,10 @@ sal_Int32 Date::GetAsNormalizedDays() const
     // This is a very common datum we often calculate from.
     if (mnDate == 18991230) // 1899-12-30
     {
-        assert(DateToDays( GetDay(), GetMonth(), GetYear() ) == 693594);
+#ifndef NDEBUG
+        static sal_Int32 nDays = DateToDays( GetDay(), GetMonth(), GetYear());
+        assert(nDays == 693594);
+#endif
         return 693594;
     }
     // Not calling comphelper::date::convertDateToDaysNormalizing() here just

Reply via email to