summaryrefslogtreecommitdiff
path: root/sc/source/core/data/dptabres.cxx
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2016-11-20 14:07:29 +0100
committerTamás Zolnai <tamas.zolnai@collabora.com>2016-11-20 14:07:29 +0100
commite2ebfc5d5378453a0e1df5d37851def54e29b04b (patch)
treea5b201918ad7f82c3c81a33c222779bab3ba500f /sc/source/core/data/dptabres.cxx
parentf463d68c66f5d12352a55413ae02352451101c5d (diff)
Simplify this code.
Change-Id: I2a82d99277114135c4dde8ef83fc454329411c21
Diffstat (limited to 'sc/source/core/data/dptabres.cxx')
-rw-r--r--sc/source/core/data/dptabres.cxx15
1 files changed, 9 insertions, 6 deletions
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index 233329c854ac..9f2b53debbf7 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -547,13 +547,16 @@ void ScDPAggData::Calculate( ScSubTotalFunc eFunc, const ScDPSubTotalState& rSub
fResult = (fAux - fVal*fVal/(double)(nCount)) / (double)nCount;
break;
case SUBTOTAL_FUNC_MED:
- if (mSortedValues.size() > 0)
{
- assert(mSortedValues.size() == static_cast<size_t>(nCount));
- if ((mSortedValues.size() % 2) == 1)
- fResult = mSortedValues[mSortedValues.size() / 2];
- else
- fResult = (mSortedValues[mSortedValues.size() / 2 - 1] + mSortedValues[mSortedValues.size() / 2]) / 2.0;
+ size_t nSize = mSortedValues.size();
+ if (nSize > 0)
+ {
+ assert(nSize == static_cast<size_t>(nCount));
+ if ((nSize % 2) == 1)
+ fResult = mSortedValues[nSize / 2];
+ else
+ fResult = (mSortedValues[nSize / 2 - 1] + mSortedValues[nSize / 2]) / 2.0;
+ }
}
break;
default: