sc/source/core/data/table2.cxx |   23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

New commits:
commit b35f6971561bc095965e82f230e0307f6694228b
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Fri Jan 22 21:17:25 2021 +0000
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Sun Jan 24 03:01:59 2021 +0100

    sc: GetRowForHeight performance improvement.
    
    Instead of just skipping hidden rows, either skip or interpolate
    into visible ones.
    
    This method, and it's single caller look rather unusual to me. It is
    unclear why we would want to return the results we do, and why the
    one caller subtracts a row.
    
    Some surprising proportion of tile rendering was exercising this code
    path extremely slowly.
    
    --5.94%--ScDocument::GetPrintArea
              |
              |--5.04%--ScDrawLayer::GetPrintArea
              |          ScTable::GetRowForHeight
              |          |
              |           --4.58%--ScFlatBoolRowSegments::getRangeData
              |                     |
              |                      --2.46%--ScFlatSegmentsImpl<bool, 
bool>::getRangeData
    
    Change-Id: I75418d6af59a33b99e8bb0c374139e1a4ee6ef87
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109837
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Tested-by: Michael Meeks <michael.me...@collabora.com>
    Reviewed-by: Ashod Nakashian <a...@collabora.com>
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109848
    Tested-by: Jenkins

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 1ddf2993b170..a980774c7b9d 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -3996,16 +3996,25 @@ SCROW ScTable::GetRowForHeight(sal_uLong nHeight) const
                 break;
         }
 
-        nSum += aRowHeightRange.mnValue;
+        // find the last common row between hidden & height spans
+        SCROW nLastCommon = std::min(aData.mnRow2, aRowHeightRange.mnRow2);
+        assert (nLastCommon >= nRow);
+        SCROW nCommon = nLastCommon - nRow + 1;
 
-        if (nSum > nHeight)
+        // how much further to go ?
+        sal_uLong nPixelsLeft = nHeight - nSum;
+        sal_uLong nCommonPixels = aRowHeightRange.mnValue * nCommon;
+
+        // are we in the zone ?
+        if (nCommonPixels > nPixelsLeft)
         {
+            nRow += (nPixelsLeft + aRowHeightRange.mnValue - 1) / 
aRowHeightRange.mnValue;
+
+            // FIXME: finding this next row is far from elegant,
+            // we have a single caller, which subtracts one as well(!?)
             if (nRow >= rDocument.MaxRow())
                 return rDocument.MaxRow();
 
-            // Find the next visible row.
-            ++nRow;
-
             if (!mpHiddenRows->getRangeData(nRow, aData))
                 // Failed to fetch the range data for whatever reason.
                 break;
@@ -4016,6 +4025,10 @@ SCROW ScTable::GetRowForHeight(sal_uLong nHeight) const
 
             return nRow <= rDocument.MaxRow() ? nRow : rDocument.MaxRow();
         }
+
+        // skip the range and keep hunting
+        nSum += nCommonPixels;
+        nRow = nLastCommon;
     }
     return -1;
 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to