From 4db2b19fe887cbf55d773f2af79ef5fe4d71908a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Mon, 9 May 2022 17:37:01 +0200 Subject: [PATCH] avoid somewhat expensive mdds position() call if possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I095f6285b9e1da5869ca08a0d8e6fae9ace40cfa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134126 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- sc/source/core/data/queryiter.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 #include +#include #include #include @@ -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 {