diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2022-05-09 17:37:01 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2022-05-11 11:49:48 +0200 |
commit | 4db2b19fe887cbf55d773f2af79ef5fe4d71908a (patch) | |
tree | 15c77831527081e24e506b494fef3b83ffa12e24 | |
parent | 5b189abc13d4a9e408c82298e4ede0fdf505002d (diff) |
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.lunak@collabora.com>
-rw-r--r-- | sc/source/core/data/queryiter.cxx | 8 |
1 files changed, 7 insertions, 1 deletions
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 { |