summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2016-05-13 16:34:09 +0200
committerDavid Tardon <dtardon@redhat.com>2016-05-13 16:46:56 +0200
commit07794b4c221dceb06da4d4b3fd7e3678457663af (patch)
tree0b4773bffdbd932d3419d552b2de84ab72d18a23 /chart2
parentf9c92771af05886c2d35f4446d514488fd448109 (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
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/view/charttypes/VSeriesPlotter.cxx9
1 files changed, 7 insertions, 2 deletions
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index fff2eeb18114..2f736785b503 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++ )