summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-02-01 12:47:53 +0000
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-02-01 15:12:25 +0100
commite4410bd37fc018c851b5ebf9cf011d59af6a2ad9 (patch)
treed90825c7f280a3fceee22bdebf1322987bfb06c4
parent15329e96c78232ee37102d24d221c01f0e209a29 (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>
-rw-r--r--sc/inc/fillinfo.hxx2
-rw-r--r--sc/source/core/data/fillinfo.cxx9
-rw-r--r--sc/source/ui/app/inputhdl.cxx2
-rw-r--r--sc/source/ui/miscdlgs/datatableview.cxx2
-rw-r--r--sc/source/ui/view/gridwin.cxx2
-rw-r--r--sc/source/ui/view/gridwin4.cxx4
-rw-r--r--sc/source/ui/view/printfun.cxx6
7 files changed, 16 insertions, 11 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/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index d53637456af1..b456f9ea1ab6 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -1051,14 +1051,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 1c5f0a108f69..1f5ae2869c6e 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 0f3f9ff8b92b..3cf47209647c 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5100,7 +5100,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 63d279dd57d2..892ac654c477 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() );
@@ -1573,7 +1573,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 87edd0e132a2..ded6a6e04420 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -554,7 +554,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 );
@@ -1399,7 +1399,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");
@@ -1611,7 +1611,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 );