sc/source/core/data/conditio.cxx | 60 ++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 25 deletions(-)
New commits: commit 667aa6ade94a4dee441868d21db037e42c871932 Author: Eike Rathke <er...@redhat.com> Date: Wed Jul 19 19:10:32 2017 +0200 Avoid temporary Date and normalization Rather than possibly calculating Date=((Date=(Date+int))+int) with a normalization involved for each operator+() force Date=(Date+(int+int)) Change-Id: I6c4b30749d138c0b041ffc9e37796b6f64b6d461 diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 9cdb73ea3196..3f83ea2de188 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1649,8 +1649,8 @@ bool ScCondDateFormatEntry::IsValid( const ScAddress& rPos ) const const DayOfWeek eDay = rActDate.GetDayOfWeek(); if( eDay != SUNDAY ) { - Date aBegin(rActDate - 8 - static_cast<sal_Int32>(eDay)); - Date aEnd(rActDate - 2 - static_cast<sal_Int32>(eDay)); + Date aBegin(rActDate - (8 + static_cast<sal_Int32>(eDay))); + Date aEnd(rActDate - (2 + static_cast<sal_Int32>(eDay))); return aCellDate.IsBetween( aBegin, aEnd ); } else @@ -1666,8 +1666,8 @@ bool ScCondDateFormatEntry::IsValid( const ScAddress& rPos ) const const DayOfWeek eDay = rActDate.GetDayOfWeek(); if( eDay != SUNDAY ) { - Date aBegin(rActDate - 1 - static_cast<sal_Int32>(eDay)); - Date aEnd(rActDate + 5 - static_cast<sal_Int32>(eDay)); + Date aBegin(rActDate - (1 + static_cast<sal_Int32>(eDay))); + Date aEnd(rActDate + (5 + static_cast<sal_Int32>(eDay))); return aCellDate.IsBetween( aBegin, aEnd ); } else @@ -1682,8 +1682,8 @@ bool ScCondDateFormatEntry::IsValid( const ScAddress& rPos ) const const DayOfWeek eDay = rActDate.GetDayOfWeek(); if( eDay != SUNDAY ) { - return aCellDate.IsBetween( rActDate + 6 - static_cast<sal_Int32>(eDay), - rActDate + 12 - static_cast<sal_Int32>(eDay) ); + return aCellDate.IsBetween( rActDate + (6 - static_cast<sal_Int32>(eDay)), + rActDate + (12 - static_cast<sal_Int32>(eDay)) ); } else { commit ef8f13e08bccb7c082d3c5b19cce8a7a63c0b2fa Author: Eike Rathke <er...@redhat.com> Date: Wed Jul 19 18:49:55 2017 +0200 Don't calculate GetDayOfWeek() thrice Change-Id: Ia1f7689448f8a9ea9e5c1a6e3b1949ee2065c827 diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 3e9ec4c10b80..9cdb73ea3196 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1645,40 +1645,50 @@ bool ScCondDateFormatEntry::IsValid( const ScAddress& rPos ) const return true; break; case condformat::LASTWEEK: - if( rActDate.GetDayOfWeek() != SUNDAY ) { - Date aBegin(rActDate - 8 - static_cast<sal_Int32>(rActDate.GetDayOfWeek())); - Date aEnd(rActDate - 2 - static_cast<sal_Int32>(rActDate.GetDayOfWeek())); - return aCellDate.IsBetween( aBegin, aEnd ); - } - else - { - Date aBegin(rActDate - 8); - Date aEnd(rActDate - 1); - return aCellDate.IsBetween( aBegin, aEnd ); + const DayOfWeek eDay = rActDate.GetDayOfWeek(); + if( eDay != SUNDAY ) + { + Date aBegin(rActDate - 8 - static_cast<sal_Int32>(eDay)); + Date aEnd(rActDate - 2 - static_cast<sal_Int32>(eDay)); + return aCellDate.IsBetween( aBegin, aEnd ); + } + else + { + Date aBegin(rActDate - 8); + Date aEnd(rActDate - 1); + return aCellDate.IsBetween( aBegin, aEnd ); + } } break; case condformat::THISWEEK: - if( rActDate.GetDayOfWeek() != SUNDAY ) { - Date aBegin(rActDate - 1 - static_cast<sal_Int32>(rActDate.GetDayOfWeek())); - Date aEnd(rActDate + 5 - static_cast<sal_Int32>(rActDate.GetDayOfWeek())); - return aCellDate.IsBetween( aBegin, aEnd ); - } - else - { - Date aEnd( rActDate + 6); - return aCellDate.IsBetween( rActDate, aEnd ); + const DayOfWeek eDay = rActDate.GetDayOfWeek(); + if( eDay != SUNDAY ) + { + Date aBegin(rActDate - 1 - static_cast<sal_Int32>(eDay)); + Date aEnd(rActDate + 5 - static_cast<sal_Int32>(eDay)); + return aCellDate.IsBetween( aBegin, aEnd ); + } + else + { + Date aEnd( rActDate + 6); + return aCellDate.IsBetween( rActDate, aEnd ); + } } break; case condformat::NEXTWEEK: - if( rActDate.GetDayOfWeek() != SUNDAY ) - { - return aCellDate.IsBetween( rActDate + 6 - static_cast<sal_Int32>(rActDate.GetDayOfWeek()), rActDate + 12 - static_cast<sal_Int32>(rActDate.GetDayOfWeek()) ); - } - else { - return aCellDate.IsBetween( rActDate + 7, rActDate + 13 ); + const DayOfWeek eDay = rActDate.GetDayOfWeek(); + if( eDay != SUNDAY ) + { + return aCellDate.IsBetween( rActDate + 6 - static_cast<sal_Int32>(eDay), + rActDate + 12 - static_cast<sal_Int32>(eDay) ); + } + else + { + return aCellDate.IsBetween( rActDate + 7, rActDate + 13 ); + } } break; case condformat::LASTMONTH: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits