sc/source/core/data/table3.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
New commits: commit 5e9c2677e8fcd19b289d947b94ceba52b138728b Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Mon Nov 8 17:45:14 2021 +0100 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Mon Nov 8 21:39:08 2021 +0100 improve performance of cell equality comparisons (tdf#139444) When comparing cell and a string for (in)equality, that means comparing the whole cell, even when not explicitly asked for. Whole cell comparison is simpler and faster. Change-Id: Ic7a79b20f710f2a5d84f62c714d67c088a22d449 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124881 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 9c7417278658..02c2619624b5 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -2705,6 +2705,12 @@ public: // Simple string matching i.e. no regexp match. if (isTextMatchOp(rEntry)) { + bool matchWholeCell = bMatchWholeCell; + // When comparing for (in)equality, we can simply compare the whole cell + // even when not explicitly asked, and that code is faster (it's simpler, + // no SharedString temporary, etc.). + if( rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL ) + matchWholeCell = true; if (rItem.meType != ScQueryEntry::ByString && rItem.maString.isEmpty()) { // #i18374# When used from functions (match, countif, sumif, vlookup, hlookup, lookup), @@ -2714,7 +2720,7 @@ public: if ( rEntry.eOp == SC_NOT_EQUAL ) bOk = !bOk; } - else if ( bMatchWholeCell ) + else if ( matchWholeCell ) { if (pValueSource1) { @@ -2752,7 +2758,7 @@ public: sal_Int32 nStrPos; if (!mbCaseSensitive) - { // Common case for vlookup etc. + { const svl::SharedString rSource(pValueSource1? *pValueSource1 : mrStrPool.intern(*pValueSource2)); const rtl_uString *pQuer = rItem.maString.getDataIgnoreCase();