diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-19 10:58:41 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-19 18:44:42 +0200 |
commit | c3ea4a8025f1ba241a8ac5c53ac79fd274ec6b3a (patch) | |
tree | 5b79eb43cafa309887f0ab56954d0e54178f8613 | |
parent | 0b6ea30e5825d7b11c783c4e5c4397acff9cac4a (diff) |
use optional in processEntry
which means we save the cost of initialising an OUString
Change-Id: Ib139383b43f6d49303e20368ce4177b068c38ed9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140176
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sc/source/core/data/queryevaluator.cxx | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/sc/source/core/data/queryevaluator.cxx b/sc/source/core/data/queryevaluator.cxx index b5ff8a354c84..2562e513c670 100644 --- a/sc/source/core/data/queryevaluator.cxx +++ b/sc/source/core/data/queryevaluator.cxx @@ -766,19 +766,15 @@ std::pair<bool, bool> ScQueryEvaluator::processEntry(SCROW nRow, SCCOL nCol, ScR } } const svl::SharedString* cellSharedString = nullptr; - OUString cellString; - bool cellStringSet = false; + std::optional<OUString> oCellString; const bool bFastCompareByString = isFastCompareByString(rEntry); if (rEntry.eOp == SC_EQUAL && rItems.size() >= 10 && bFastCompareByString) { // The same as above but for strings. Try to optimize the case when // it's a svl::SharedString comparison. That happens when SC_EQUAL is used // and simple matching is used, see compareByString() - if (!cellStringSet) - { - cellString = getCellString(aCell, nRow, rEntry.nField, &cellSharedString); - cellStringSet = true; - } + if (!oCellString) + oCellString = getCellString(aCell, nRow, rEntry.nField, &cellSharedString); // Allow also checking ScQueryEntry::ByValue if the cell is not numeric, // as in that case isQueryByNumeric() would be false and isQueryByString() would // be true because of SC_EQUAL making isTextMatchOp() true. @@ -858,18 +854,15 @@ std::pair<bool, bool> ScQueryEvaluator::processEntry(SCROW nRow, SCCOL nCol, ScR } else if (isQueryByString(rEntry.eOp, rItem.meType, aCell)) { - if (!cellStringSet) - { - cellString = getCellString(aCell, nRow, rEntry.nField, &cellSharedString); - cellStringSet = true; - } + if (!oCellString) + oCellString = getCellString(aCell, nRow, rEntry.nField, &cellSharedString); std::pair<bool, bool> aThisRes; if (cellSharedString && bFastCompareByString) // fast aThisRes = compareByString<true>(rEntry, rItem, cellSharedString, nullptr); else if (cellSharedString) aThisRes = compareByString(rEntry, rItem, cellSharedString, nullptr); else - aThisRes = compareByString(rEntry, rItem, nullptr, &cellString); + aThisRes = compareByString(rEntry, rItem, nullptr, &*oCellString); aRes.first |= aThisRes.first; aRes.second |= aThisRes.second; } |