sc/source/filter/oox/sheetdatabuffer.cxx |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

New commits:
commit adce63eb131f0b20a1d72797d92f07efcee75ec4
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Sun Jun 4 18:53:03 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Jun 5 11:55:11 2023 +0200

    sort row-range-styles
    
    which reduces the amount of data-movement we do in the following loop
    when inserting into the sorted_vector.
    Shaves 2% off the load time of a large document with lots of styles.
    
    Change-Id: I8df4cc35edcc212613068af108b136c2d5acd219
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152600
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx 
b/sc/source/filter/oox/sheetdatabuffer.cxx
index 280c39f70c10..5632d8356353 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -390,10 +390,17 @@ void SheetDataBuffer::addColXfStyleProcessRowRanges()
     for ( sal_Int32 nCol = 0; nCol <= nMaxCol; ++nCol )
     {
         RowStyles& rRowStyles = maStylesPerColumn[ nCol ];
-        for ( const auto& [nXfId, rRowRangeList] : maXfIdRowRangeList )
+        for ( auto& [nXfId, rRowRangeList] : maXfIdRowRangeList )
         {
             if ( nXfId == -1 ) // it's a dud skip it
                 continue;
+            // sort the row ranges, so we spend less time moving data around
+            // when we insert into aStyleRows
+            std::sort(rRowRangeList.begin(), rRowRangeList.end(),
+                [](const ValueRange& lhs, const ValueRange& rhs)
+                {
+                    return lhs.mnFirst < rhs.mnFirst;
+                });
             // get all row ranges for id
             for ( const auto& rRange : rRowRangeList )
             {

Reply via email to