sc/source/core/data/queryiter.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
New commits: commit 4db2b19fe887cbf55d773f2af79ef5fe4d71908a Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Mon May 9 17:37:01 2022 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Wed May 11 11:49:48 2022 +0200 avoid somewhat expensive mdds position() call if possible Change-Id: I095f6285b9e1da5869ca08a0d8e6fae9ace40cfa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134126 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sc/source/core/data/queryiter.cxx b/sc/source/core/data/queryiter.cxx index 75a2fe28b7a6..0cd1a19ec744 100644 --- a/sc/source/core/data/queryiter.cxx +++ b/sc/source/core/data/queryiter.cxx @@ -20,6 +20,7 @@ #include <queryiter.hxx> #include <comphelper/flagguard.hxx> +#include <o3tl/safeint.hxx> #include <svl/numformat.hxx> #include <svl/zforlist.hxx> @@ -1106,7 +1107,12 @@ void ScQueryCellIteratorAccessSpecific< ScQueryCellIteratorAccess::SortedCache > { ++sortedCachePos; nRow = sortedCache->rowForIndex(sortedCachePos); - maCurPos = rCol.maCells.position(nRow); + // Avoid mdds position() call if row is in the same block. + if(maCurPos.first != rCol.maCells.end() && o3tl::make_unsigned(nRow) >= maCurPos.first->position + && o3tl::make_unsigned(nRow) < maCurPos.first->position + maCurPos.first->size) + maCurPos.second = nRow - maCurPos.first->position; + else + maCurPos = rCol.maCells.position(nRow); } else {