diff options
author | David Tardon <dtardon@redhat.com> | 2016-05-13 16:34:09 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-05-18 19:30:35 +0000 |
commit | cb91beeb29ba27afe29b02711e942818017bab3c (patch) | |
tree | 96aba553aa367cb8c6df51db5deb87542ae028cc | |
parent | 7c105b0014b59349bd110b249e1865d9e6abbb94 (diff) |
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
(cherry picked from commit 07794b4c221dceb06da4d4b3fd7e3678457663af)
Reviewed-on: https://gerrit.libreoffice.org/24977
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r-- | chart2/source/view/charttypes/BarChart.cxx | 9 | ||||
-rw-r--r-- | chart2/source/view/charttypes/VSeriesPlotter.cxx | 11 |
2 files changed, 16 insertions, 4 deletions
diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx index cd2019ed024d..048fd0caad59 100644 --- a/chart2/source/view/charttypes/BarChart.cxx +++ b/chart2/source/view/charttypes/BarChart.cxx @@ -468,6 +468,10 @@ void BarChart::createShapes() if( aLogicYSumMap.find(nAttachedAxisIndex)==aLogicYSumMap.end() ) aLogicYSumMap[nAttachedAxisIndex]=0.0; + const sal_Int32 nSlotPoints = aXSlotIter->getPointCount(); + if( nPointIndex >= nSlotPoints ) + continue; + double fMinimumY = 0.0, fMaximumY = 0.0; aXSlotIter->calculateYMinAndMaxForCategory( nPointIndex , isSeparateStackingForDifferentSigns( 1 ), fMinimumY, fMaximumY, nAttachedAxisIndex ); @@ -510,8 +514,9 @@ void BarChart::createShapes() // get distance from base value to maximum and minimum double fMinimumY = 0.0, fMaximumY = 0.0; - aXSlotIter->calculateYMinAndMaxForCategory( nPointIndex - , isSeparateStackingForDifferentSigns( 1 ), fMinimumY, fMaximumY, nAttachedAxisIndex ); + if( nPointIndex < aXSlotIter->getPointCount()) + aXSlotIter->calculateYMinAndMaxForCategory( nPointIndex + , isSeparateStackingForDifferentSigns( 1 ), fMinimumY, fMaximumY, nAttachedAxisIndex ); double fLogicPositiveYSum = 0.0; if( !::rtl::math::isNan( fMaximumY ) ) diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 4ed9bdcd5a28..f8206ab831bd 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -1847,11 +1847,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]; @@ -1945,6 +1947,11 @@ void VDataSeriesGroup::calculateYMinAndMaxForCategoryRange( //iterate through the given categories if(nStartCategoryIndex<0) nStartCategoryIndex=0; + const sal_Int32 nPointCount = getPointCount();//necessary to create m_aListOfCachedYValues + if(nPointCount <= 0) + return; + if (nEndCategoryIndex >= nPointCount) + nEndCategoryIndex = nPointCount - 1; if(nEndCategoryIndex<0) nEndCategoryIndex=0; for( sal_Int32 nCatIndex = nStartCategoryIndex; nCatIndex <= nEndCategoryIndex; nCatIndex++ ) |