[Libreoffice-commits] core.git: sc/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 16 16:20:16 UTC 2021


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

New commits:
commit 4461e14d08c7d1c1c43b136a5a8e3acb868c0b51
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Jul 16 14:47:30 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jul 16 18:19:41 2021 +0200

    avoid a map lookup on a hot path
    
    Change-Id: I4e514c7212c0b349796f3791b4c7f3f06d3fa22a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119064
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx
index e497ee44f8d8..e846d15a5b4c 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -101,11 +101,11 @@ void CellBlockBuffer::setColSpans( sal_Int32 nRow, const ValueRangeSet& rColSpan
 {
     OSL_ENSURE( maColSpans.count( nRow ) == 0, "CellBlockBuffer::setColSpans - multiple column spans for the same row" );
     OSL_ENSURE( (mnCurrRow < nRow) && (maColSpans.empty() || (maColSpans.rbegin()->first < nRow)), "CellBlockBuffer::setColSpans - rows are unsorted" );
-    if( (mnCurrRow < nRow) && (maColSpans.count( nRow ) == 0) )
-    {
-        maColSpans[ nRow ] = rColSpans.getRanges();
+    if( mnCurrRow >= nRow )
+        return;
+    auto pair = maColSpans.try_emplace(nRow, rColSpans.getRanges());
+    if( pair.second ) // insert happened
         mnCurrRow = nRow;
-    }
 }
 
 SheetDataBuffer::SheetDataBuffer( const WorksheetHelper& rHelper ) :


More information about the Libreoffice-commits mailing list