diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-02-01 12:47:53 +0000 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-02-06 18:11:54 +0100 |
commit | b77d256b96c5cfb34fa953b3ffc64c664b2a7743 (patch) | |
tree | 371e9f131af3ba9fa6c6bbe20552029af63deca3 /sc | |
parent | 1d5d02e099a5465a82613044a8a61cd618c877c3 (diff) |
perf: limit to max 1024 rows in cases where we originally allocated 1024 rows
so everywhere before:
commit a86c00414a43c5d87981ffae1018cb242c5e5e1d
Date: Fri Jan 19 14:27:10 2024 +0200
cool#6893 reduce allocation in ScGridWindow::PaintTile
where ScTableInfo was used with no args, pass true to indicate this is
just a hint, and where it was originally passed an explicit number, pass
false for "hint" (which was just one case, the case that now passes
TopLeftTileRow, nBottomRightTileRow.
When hint is true limit to max of 1024 rows, and the apparent case
is visible in ScGridWindow::UpdateFormulaRange at
https://github.com/CollaboraOnline/online/issues/6893#issuecomment-1921141048
Change-Id: Iebe890c3ac967800b60150aaa71f7e845a021f60
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162875
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
(cherry picked from commit e4410bd37fc018c851b5ebf9cf011d59af6a2ad9)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163016
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/fillinfo.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_condformat.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/fillinfo.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/datatableview.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin4.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/printfun.cxx | 6 |
8 files changed, 17 insertions, 12 deletions
diff --git a/sc/inc/fillinfo.hxx b/sc/inc/fillinfo.hxx index 30e4b7540a67..68f845df42fa 100644 --- a/sc/inc/fillinfo.hxx +++ b/sc/inc/fillinfo.hxx @@ -268,7 +268,7 @@ struct ScTableInfo SCSIZE mnArrCapacity; bool mbPageMode; - explicit ScTableInfo(SCROW nStartRow, SCROW nEndRow); + explicit ScTableInfo(SCROW nStartRow, SCROW nEndRow, bool bHintOnly); ~ScTableInfo(); ScTableInfo(const ScTableInfo&) = delete; const ScTableInfo& operator=(const ScTableInfo&) = delete; diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx index 1b7480b2fc9a..53072640324e 100644 --- a/sc/qa/unit/ucalc_condformat.cxx +++ b/sc/qa/unit/ucalc_condformat.cxx @@ -366,7 +366,7 @@ CPPUNIT_TEST_FIXTURE(TestCondformat, testColorScaleInMergedCell) m_pDoc->DoMerge(0, 0, 0, 1, 0); // A1:A2 CPPUNIT_ASSERT(m_pDoc->IsMerged(ScAddress(0, 0, 0))); - ScTableInfo aTabInfo(0, 2); + ScTableInfo aTabInfo(0, 2, false); m_pDoc->FillInfo(aTabInfo, 0, 0, 0, 1, 0, 1, 1, false, false); RowInfo* pRowInfo = aTabInfo.mpRowInfo.get(); diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index e9fef2c0cf08..4f643a04dae3 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -1071,14 +1071,19 @@ void ScDocument::FillInfo( /// We seem to need to allocate three extra rows here, not sure why /// -ScTableInfo::ScTableInfo(SCROW nStartRow, SCROW nEndRow) +ScTableInfo::ScTableInfo(SCROW nStartRow, SCROW nEndRow, bool bHintOnly) : mnArrCount(0) , mnArrCapacity(nEndRow - nStartRow + 4) , mbPageMode(false) { assert(nStartRow >= 0); assert(nEndRow >= nStartRow); - mpRowInfo.reset(new RowInfo[nEndRow - nStartRow + 4] {}); + if (bHintOnly && mnArrCapacity > 1024) + { + SAL_WARN("sc.core", "ScTableInfo excessive capacity: " << mnArrCapacity << " start: " << nStartRow << " end: " << nEndRow); + mnArrCapacity = 1024; + } + mpRowInfo.reset(new RowInfo[mnArrCapacity] {}); } ScTableInfo::~ScTableInfo() diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index cd7841a059a7..c85d57774e00 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -523,7 +523,7 @@ ReferenceMark ScInputHandler::GetReferenceMark( const ScViewData& rViewData, ScD Fraction aZoomX = rViewData.GetZoomX(); Fraction aZoomY = rViewData.GetZoomY(); - ScTableInfo aTabInfo(nY1, nY2); + ScTableInfo aTabInfo(nY1, nY2, true); pDocSh->GetDocument().FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab, nPPTX, nPPTY, false, false ); diff --git a/sc/source/ui/miscdlgs/datatableview.cxx b/sc/source/ui/miscdlgs/datatableview.cxx index 2ad901f4b110..e6f7373e0491 100644 --- a/sc/source/ui/miscdlgs/datatableview.cxx +++ b/sc/source/ui/miscdlgs/datatableview.cxx @@ -257,7 +257,7 @@ void ScDataTableView::Paint(vcl::RenderContext& rRenderContext, const tools::Rec SCCOL nMaxVisibleCol = findColFromPos(aSize.Width() - mnScrollBarSize, mpDoc.get(), mnFirstVisibleCol); SCROW nMaxVisibleRow = findRowFromPos(aSize.Height(), mpDoc.get(), mnFirstVisibleRow); - ScTableInfo aTableInfo(mnFirstVisibleRow, nMaxVisibleRow); + ScTableInfo aTableInfo(mnFirstVisibleRow, nMaxVisibleRow, true); mpDoc->FillInfo(aTableInfo, mnFirstVisibleCol, mnFirstVisibleRow, nMaxVisibleCol, nMaxVisibleRow, 0, 0.06666, 0.06666, false, false); ScOutputData aOutput(&rRenderContext, OUTTYPE_WINDOW, aTableInfo, mpDoc.get(), 0, nRowHeaderWidth, nColHeaderHeight, mnFirstVisibleCol, mnFirstVisibleRow, nMaxVisibleCol, nMaxVisibleRow, nPPTX, nPPTY); diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 3ae1a37f5066..426e0d88cf58 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -5170,7 +5170,7 @@ void ScGridWindow::UpdateFormulaRange(SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 double nPPTX = mrViewData.GetPPTX(); double nPPTY = mrViewData.GetPPTY(); - ScTableInfo aTabInfo(nY1, nY2); + ScTableInfo aTabInfo(nY1, nY2, true); rDoc.FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab, nPPTX, nPPTY, false, false ); Fraction aZoomX = mrViewData.GetZoomX(); diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 50d03d010416..1d747f709e50 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -530,7 +530,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod // data block - ScTableInfo aTabInfo(nY1, nY2); + ScTableInfo aTabInfo(nY1, nY2, true); rDoc.FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab, nPPTX, nPPTY, false, rOpts.GetOption(VOPT_FORMULAS), &mrViewData.GetMarkData() ); @@ -1576,7 +1576,7 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice, aAbsMode.SetOrigin(aOrigin); rDevice.SetMapMode(aAbsMode); - ScTableInfo aTabInfo(nTopLeftTileRow, nBottomRightTileRow); + ScTableInfo aTabInfo(nTopLeftTileRow, nBottomRightTileRow, false); rDoc.FillInfo(aTabInfo, nTopLeftTileCol, nTopLeftTileRow, nBottomRightTileCol, nBottomRightTileRow, nTab, fPPTX, fPPTY, false, false); diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index ce2053c97f61..62a0a379301f 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -557,7 +557,7 @@ void ScPrintFunc::DrawToDev(ScDocument& rDoc, OutputDevice* pDev, double /* nPri // Assemble data - ScTableInfo aTabInfo(nY1, nY2); + ScTableInfo aTabInfo(nY1, nY2, true); rDoc.FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab, nScaleX, nScaleY, false, bFormula ); lcl_HidePrint( aTabInfo, nX1, nX2 ); @@ -1402,7 +1402,7 @@ void ScPrintFunc::DrawBorder( tools::Long nScrX, tools::Long nScrY, tools::Long pBorderDoc->InitUndo( rDoc, 0,0, true,true ); pBorderDoc->ApplyAttr( 0,0,0, *pBorderData ); - ScTableInfo aTabInfo(0, 1); + ScTableInfo aTabInfo(0, 1, true); pBorderDoc->FillInfo( aTabInfo, 0,0, 0,0, 0, nScaleX, nScaleY, false, false ); OSL_ENSURE(aTabInfo.mnArrCount,"nArrCount == 0"); @@ -1614,7 +1614,7 @@ void ScPrintFunc::PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, // Assemble data - ScTableInfo aTabInfo(nY1, nY2); + ScTableInfo aTabInfo(nY1, nY2, true); rDoc.FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nPrintTab, nScaleX, nScaleY, true, aTableParam.bFormulas ); lcl_HidePrint( aTabInfo, nX1, nX2 ); |