diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2018-06-11 13:18:31 +0900 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-07-03 11:50:08 +0200 |
commit | e46df81b679cbb44235e891c81e8b30ae50b31d4 (patch) | |
tree | 69a04a958e0c5a9840f3c98a9c5f714c4d6e006f /sc | |
parent | 322083e0cf1268bc5d40f0d49eb50f00f503ef15 (diff) |
sc: A micro optimization of PERCENTILE() for interpolation cases
As the leading std::nth_element() already partitions the vector,
all we have to do is to pick the minimum in its latter part.
Change-Id: I7767edc538819251c8fe9d26441ae57b06b2f865
Reviewed-on: https://gerrit.libreoffice.org/55575
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/tool/interpr3.cxx | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx index d85d1a561073..78756b0810e8 100644 --- a/sc/source/core/tool/interpr3.cxx +++ b/sc/source/core/tool/interpr3.cxx @@ -3406,8 +3406,7 @@ double ScInterpreter::GetPercentile( vector<double> & rArray, double fPercentile { OSL_ENSURE(nIndex < nSize-1, "GetPercentile: wrong index(2)"); double fVal = *iter; - iter = rArray.begin() + nIndex+1; - ::std::nth_element( rArray.begin(), iter, rArray.end()); + iter = ::std::min_element( rArray.begin() + nIndex + 1, rArray.end()); return fVal + fDiff * (*iter - fVal); } } @@ -3438,8 +3437,7 @@ double ScInterpreter::GetPercentileExclusive( vector<double> & rArray, double fP { OSL_ENSURE(nIndex < nSize1, "GetPercentile: wrong index(2)"); double fVal = *iter; - iter = rArray.begin() + nIndex + 1; - ::std::nth_element( rArray.begin(), iter, rArray.end()); + iter = ::std::min_element( rArray.begin() + nIndex + 1, rArray.end()); return fVal + fDiff * (*iter - fVal); } } |