sc/inc/dociter.hxx | 2 sc/source/core/data/dociter.cxx | 90 ++++++++++++++++++++-------------------- 2 files changed, 46 insertions(+), 46 deletions(-)
New commits: commit 7e6897b7c3d3aaa19b793c518bee27a08732736b Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Nov 20 16:12:27 2019 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Nov 21 20:00:12 2019 +0100 ScQueryParam can be allocated inline in ScQueryCellIterator Change-Id: I9debf80755a3950cc34be280af8006e52006b14a Reviewed-on: https://gerrit.libreoffice.org/83313 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx index 3479ee67ca08..c30a4840d466 100644 --- a/sc/inc/dociter.hxx +++ b/sc/inc/dociter.hxx @@ -270,7 +270,7 @@ class ScQueryCellIterator // walk through all non-empty cells in an ar typedef sc::CellStoreType::const_position_type PositionType; PositionType maCurPos; - std::unique_ptr<ScQueryParam> mpParam; + ScQueryParam maParam; ScDocument* pDoc; const ScInterpreterContext& mrContext; SCTAB nTab; diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index 16dc6b61fd9d..391940171a69 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -1042,7 +1042,7 @@ bool ScCellIterator::next() ScQueryCellIterator::ScQueryCellIterator(ScDocument* pDocument, const ScInterpreterContext& rContext, SCTAB nTable, const ScQueryParam& rParam, bool bMod ) : - mpParam(new ScQueryParam(rParam)), + maParam(rParam), pDoc( pDocument ), mrContext( rContext ), nTab( nTable), @@ -1051,15 +1051,15 @@ ScQueryCellIterator::ScQueryCellIterator(ScDocument* pDocument, const ScInterpre bAdvanceQuery( false ), bIgnoreMismatchOnLeadingStrings( false ) { - nCol = mpParam->nCol1; - nRow = mpParam->nRow1; + nCol = maParam.nCol1; + nRow = maParam.nRow1; SCSIZE i; if (bMod) // Or else it's already inserted { - SCSIZE nCount = mpParam->GetEntryCount(); - for (i = 0; (i < nCount) && (mpParam->GetEntry(i).bDoQuery); ++i) + SCSIZE nCount = maParam.GetEntryCount(); + for (i = 0; (i < nCount) && (maParam.GetEntry(i).bDoQuery); ++i) { - ScQueryEntry& rEntry = mpParam->GetEntry(i); + ScQueryEntry& rEntry = maParam.GetEntry(i); ScQueryEntry::Item& rItem = rEntry.GetQueryItem(); sal_uInt32 nIndex = 0; bool bNumber = mrContext.GetFormatTable()->IsNumberFormat( @@ -1071,8 +1071,8 @@ ScQueryCellIterator::ScQueryCellIterator(ScDocument* pDocument, const ScInterpre void ScQueryCellIterator::InitPos() { - nRow = mpParam->nRow1; - if (mpParam->bHasHeader && mpParam->bByRow) + nRow = maParam.nRow1; + if (maParam.bHasHeader && maParam.bByRow) ++nRow; ScColumn* pCol = &(pDoc->maTabs[nTab])->aCol[nCol]; maCurPos = pCol->maCells.position(nRow); @@ -1102,16 +1102,16 @@ void ScQueryCellIterator::IncBlock() bool ScQueryCellIterator::GetThis() { assert(nTab < pDoc->GetTableCount() && "index out of bounds, FIX IT"); - const ScQueryEntry& rEntry = mpParam->GetEntry(0); + const ScQueryEntry& rEntry = maParam.GetEntry(0); const ScQueryEntry::Item& rItem = rEntry.GetQueryItem(); SCCOLROW nFirstQueryField = rEntry.nField; bool bAllStringIgnore = bIgnoreMismatchOnLeadingStrings && rItem.meType != ScQueryEntry::ByString; bool bFirstStringIgnore = bIgnoreMismatchOnLeadingStrings && - !mpParam->bHasHeader && rItem.meType == ScQueryEntry::ByString && - ((mpParam->bByRow && nRow == mpParam->nRow1) || - (!mpParam->bByRow && nCol == mpParam->nCol1)); + !maParam.bHasHeader && rItem.meType == ScQueryEntry::ByString && + ((maParam.bByRow && nRow == maParam.nRow1) || + (!maParam.bByRow && nCol == maParam.nCol1)); ScColumn* pCol = &(pDoc->maTabs[nTab])->aCol[nCol]; while (true) @@ -1119,7 +1119,7 @@ bool ScQueryCellIterator::GetThis() bool bNextColumn = maCurPos.first == pCol->maCells.end(); if (!bNextColumn) { - if (nRow > mpParam->nRow2) + if (nRow > maParam.nRow2) bNextColumn = true; } @@ -1128,7 +1128,7 @@ bool ScQueryCellIterator::GetThis() do { ++nCol; - if (nCol > mpParam->nCol2 || nCol >= pDoc->maTabs[nTab]->GetAllocatedColumnsCount()) + if (nCol > maParam.nCol2 || nCol >= pDoc->maTabs[nTab]->GetAllocatedColumnsCount()) return false; // Over and out if ( bAdvanceQuery ) { @@ -1142,8 +1142,8 @@ bool ScQueryCellIterator::GetThis() InitPos(); bFirstStringIgnore = bIgnoreMismatchOnLeadingStrings && - !mpParam->bHasHeader && rItem.meType == ScQueryEntry::ByString && - mpParam->bByRow; + !maParam.bHasHeader && rItem.meType == ScQueryEntry::ByString && + maParam.bByRow; } if (maCurPos.first->type == sc::element_type_empty) @@ -1175,7 +1175,7 @@ bool ScQueryCellIterator::GetThis() else { bool bTestEqualCondition = false; - if ( pDoc->maTabs[nTab]->ValidQuery( nRow, *mpParam, + if ( pDoc->maTabs[nTab]->ValidQuery( nRow, maParam, (nCol == static_cast<SCCOL>(nFirstQueryField) ? &aCell : nullptr), (nTestEqualCondition ? &bTestEqualCondition : nullptr), &mrContext) ) @@ -1224,7 +1224,7 @@ bool ScQueryCellIterator::GetThis() bool ScQueryCellIterator::GetFirst() { assert(nTab < pDoc->GetTableCount() && "index out of bounds, FIX IT"); - nCol = mpParam->nCol1; + nCol = maParam.nCol1; InitPos(); return GetThis(); } @@ -1241,10 +1241,10 @@ bool ScQueryCellIterator::GetNext() void ScQueryCellIterator::AdvanceQueryParamEntryField() { - SCSIZE nEntries = mpParam->GetEntryCount(); + SCSIZE nEntries = maParam.GetEntryCount(); for ( SCSIZE j = 0; j < nEntries; j++ ) { - ScQueryEntry& rEntry = mpParam->GetEntry( j ); + ScQueryEntry& rEntry = maParam.GetEntry( j ); if ( rEntry.bDoQuery ) { if ( rEntry.nField < pDoc->MaxCol() ) @@ -1271,18 +1271,18 @@ bool ScQueryCellIterator::FindEqualOrSortedLastInRange( SCCOL& nFoundCol, bool const mb; BoolResetter( bool& r, bool b ) : mr(r), mb(r) { r = b; } ~BoolResetter() { mr = mb; } - } aRangeLookupResetter( mpParam->mbRangeLookup, true); + } aRangeLookupResetter( maParam.mbRangeLookup, true); nFoundCol = pDoc->MaxCol()+1; nFoundRow = pDoc->MaxRow()+1; SetStopOnMismatch( true ); // assume sorted keys SetTestEqualCondition( true ); bIgnoreMismatchOnLeadingStrings = true; - bool bLiteral = mpParam->eSearchType == utl::SearchParam::SearchType::Normal && - mpParam->GetEntry(0).GetQueryItem().meType == ScQueryEntry::ByString; - bool bBinary = mpParam->bByRow && - (bLiteral || mpParam->GetEntry(0).GetQueryItem().meType == ScQueryEntry::ByValue) && - (mpParam->GetEntry(0).eOp == SC_LESS_EQUAL || mpParam->GetEntry(0).eOp == SC_GREATER_EQUAL); + bool bLiteral = maParam.eSearchType == utl::SearchParam::SearchType::Normal && + maParam.GetEntry(0).GetQueryItem().meType == ScQueryEntry::ByString; + bool bBinary = maParam.bByRow && + (bLiteral || maParam.GetEntry(0).GetQueryItem().meType == ScQueryEntry::ByValue) && + (maParam.GetEntry(0).eOp == SC_LESS_EQUAL || maParam.GetEntry(0).eOp == SC_GREATER_EQUAL); bool bFound = false; if (bBinary) { @@ -1290,7 +1290,7 @@ bool ScQueryCellIterator::FindEqualOrSortedLastInRange( SCCOL& nFoundCol, { // BinarySearch() already positions correctly and only needs real // query comparisons afterwards, skip the verification check below. - mpParam->mbRangeLookup = false; + maParam.mbRangeLookup = false; bFound = GetThis(); } } @@ -1321,19 +1321,19 @@ bool ScQueryCellIterator::FindEqualOrSortedLastInRange( SCCOL& nFoundCol, nCol = nFoundCol; nRow = nFoundRow; maCurPos = aPosSave; - if (mpParam->mbRangeLookup) + if (maParam.mbRangeLookup) { // Verify that the found entry does not only fulfill the range // lookup but also the real query, i.e. not numeric was found // if query is ByString and vice versa. - mpParam->mbRangeLookup = false; + maParam.mbRangeLookup = false; // Step back the last field advance if GetNext() did one. if (bAdvanceQuery && nColDiff) { - SCSIZE nEntries = mpParam->GetEntryCount(); + SCSIZE nEntries = maParam.GetEntryCount(); for (SCSIZE j=0; j < nEntries; ++j) { - ScQueryEntry& rEntry = mpParam->GetEntry( j ); + ScQueryEntry& rEntry = maParam.GetEntry( j ); if (rEntry.bDoQuery) { if (rEntry.nField - nColDiff >= 0) @@ -1359,10 +1359,10 @@ bool ScQueryCellIterator::FindEqualOrSortedLastInRange( SCCOL& nFoundCol, if ( IsEqualConditionFulfilled() ) { // Position on last equal entry. - SCSIZE nEntries = mpParam->GetEntryCount(); + SCSIZE nEntries = maParam.GetEntryCount(); for ( SCSIZE j = 0; j < nEntries; j++ ) { - ScQueryEntry& rEntry = mpParam->GetEntry( j ); + ScQueryEntry& rEntry = maParam.GetEntry( j ); if ( rEntry.bDoQuery ) { switch ( rEntry.eOp ) @@ -1396,15 +1396,15 @@ bool ScQueryCellIterator::FindEqualOrSortedLastInRange( SCCOL& nFoundCol, maCurPos = aPosSave; return true; } - if ( (mpParam->eSearchType != utl::SearchParam::SearchType::Normal) && + if ( (maParam.eSearchType != utl::SearchParam::SearchType::Normal) && StoppedOnMismatch() ) { // Assume found entry to be the last value less than respectively // greater than the query. But keep on searching for an equal match. - SCSIZE nEntries = mpParam->GetEntryCount(); + SCSIZE nEntries = maParam.GetEntryCount(); for ( SCSIZE j = 0; j < nEntries; j++ ) { - ScQueryEntry& rEntry = mpParam->GetEntry( j ); + ScQueryEntry& rEntry = maParam.GetEntry( j ); if ( rEntry.bDoQuery ) { switch ( rEntry.eOp ) @@ -1789,24 +1789,24 @@ bool ScQueryCellIterator::BinarySearch() // TODO: This will be extremely slow with mdds::multi_type_vector. assert(nTab < pDoc->GetTableCount() && "index out of bounds, FIX IT"); - nCol = mpParam->nCol1; + nCol = maParam.nCol1; ScColumn* pCol = &(pDoc->maTabs[nTab])->aCol[nCol]; if (pCol->IsEmptyData()) return false; - CollatorWrapper* pCollator = (mpParam->bCaseSens ? ScGlobal::GetCaseCollator() : + CollatorWrapper* pCollator = (maParam.bCaseSens ? ScGlobal::GetCaseCollator() : ScGlobal::GetCollator()); SvNumberFormatter& rFormatter = *(mrContext.GetFormatTable()); - const ScQueryEntry& rEntry = mpParam->GetEntry(0); + const ScQueryEntry& rEntry = maParam.GetEntry(0); const ScQueryEntry::Item& rItem = rEntry.GetQueryItem(); bool bLessEqual = rEntry.eOp == SC_LESS_EQUAL; bool bByString = rItem.meType == ScQueryEntry::ByString; bool bAllStringIgnore = bIgnoreMismatchOnLeadingStrings && !bByString; bool bFirstStringIgnore = bIgnoreMismatchOnLeadingStrings && - !mpParam->bHasHeader && bByString; + !maParam.bHasHeader && bByString; - nRow = mpParam->nRow1; - if (mpParam->bHasHeader) + nRow = maParam.nRow1; + if (maParam.bHasHeader) ++nRow; ScRefCellValue aCell; @@ -1827,7 +1827,7 @@ bool ScQueryCellIterator::BinarySearch() } } - NonEmptyCellIndexer aIndexer(pCol->maCells, nRow, mpParam->nRow2, bAllStringIgnore); + NonEmptyCellIndexer aIndexer(pCol->maCells, nRow, maParam.nRow2, bAllStringIgnore); if (!aIndexer.isValid()) return false; @@ -2035,7 +2035,7 @@ bool ScQueryCellIterator::BinarySearch() } aCellData = aIndexer.getCell(nLo); - if (nLo <= nHi && aCellData.second <= mpParam->nRow2) + if (nLo <= nHi && aCellData.second <= maParam.nRow2) { nRow = aCellData.second; maCurPos = aIndexer.getPosition(nLo); @@ -2043,7 +2043,7 @@ bool ScQueryCellIterator::BinarySearch() } else { - nRow = mpParam->nRow2 + 1; + nRow = maParam.nRow2 + 1; // Set current position to the last possible row. maCurPos.first = pCol->maCells.end(); --maCurPos.first; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits