[Libreoffice-commits] core.git: chart2/source

David Tardon dtardon at redhat.com
Fri May 13 14:47:55 UTC 2016


 chart2/source/view/charttypes/VSeriesPlotter.cxx |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 07794b4c221dceb06da4d4b3fd7e3678457663af
Author: David Tardon <dtardon at redhat.com>
Date:   Fri May 13 16:34:09 2016 +0200

    tdf#35957 check for preconditions earlier
    
    This cuts the number of calls of
    chart::VSeriesPlotter::calculateYMinAndMaxForCategory from ~10 billion
    to 1760 and load time from a minute to a second...
    
    Change-Id: I8ec07d82aa0e915659ce4cbdf6cd1bdd381d6245

diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index fff2eeb..2f73678 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -1852,11 +1852,13 @@ void VDataSeriesGroup::calculateYMinAndMaxForCategory( sal_Int32 nCategoryIndex
         , bool bSeparateStackingForDifferentSigns
         , double& rfMinimumY, double& rfMaximumY, sal_Int32 nAxisIndex )
 {
+    assert(nCategoryIndex >= 0);
+    assert(nCategoryIndex < getPointCount());
+
     ::rtl::math::setInf(&rfMinimumY, false);
     ::rtl::math::setInf(&rfMaximumY, true);
 
-    sal_Int32 nPointCount = getPointCount();//necessary to create m_aListOfCachedYValues
-    if(nCategoryIndex<0 || nCategoryIndex>=nPointCount || m_aSeriesVector.empty())
+    if(m_aSeriesVector.empty())
         return;
 
     CachedYValues aCachedYValues = m_aListOfCachedYValues[nCategoryIndex][nAxisIndex];
@@ -1950,6 +1952,9 @@ void VDataSeriesGroup::calculateYMinAndMaxForCategoryRange(
     //iterate through the given categories
     if(nStartCategoryIndex<0)
         nStartCategoryIndex=0;
+    const sal_Int32 nPointCount = getPointCount();//necessary to create m_aListOfCachedYValues
+    if (nEndCategoryIndex >= nPointCount)
+        nEndCategoryIndex = nPointCount - 1;
     if(nEndCategoryIndex<0)
         nEndCategoryIndex=0;
     for( sal_Int32 nCatIndex = nStartCategoryIndex; nCatIndex <= nEndCategoryIndex; nCatIndex++ )


More information about the Libreoffice-commits mailing list