diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-01-14 10:55:02 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-01-14 10:58:25 -0500 |
commit | df9243626b39742a9a148bea95796f8824fee68a (patch) | |
tree | d379108efde9e05bbd00bd953a02d040add64ef4 /sc/source/ui/view | |
parent | bbdb7b43e639b0dd27377d104c59fea3f8481b2a (diff) |
fdo#73606: Avoid excessive and unnecessary heap allocation of array objects.
This is a leftover from the 1 million row conversion we did years ago.
Change-Id: Ib50819ed51c7017bcc559bfc8b6062ff46615d09
Diffstat (limited to 'sc/source/ui/view')
-rw-r--r-- | sc/source/ui/view/viewfun2.cxx | 24 | ||||
-rw-r--r-- | sc/source/ui/view/viewfunc.cxx | 2 |
2 files changed, 13 insertions, 13 deletions
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 69658f282827..fb07797d1f0e 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -81,6 +81,7 @@ #include "prnsave.hxx" #include "searchresults.hxx" #include "tokenarray.hxx" +#include <columnspanset.hxx> #include <boost/scoped_ptr.hpp> #include <vector> @@ -107,12 +108,12 @@ sal_Bool ScViewFunc::AdjustBlockHeight( sal_Bool bPaint, ScMarkData* pMarkData ) pMarkData = &GetViewData()->GetMarkData(); ScDocument* pDoc = pDocSh->GetDocument(); - SCCOLROW* pRanges = new SCCOLROW[MAXCOLROWCOUNT]; - SCCOLROW nRangeCnt = pMarkData->GetMarkRowRanges( pRanges ); - if (nRangeCnt == 0) + std::vector<sc::RowSpan> aMarkedRows; + pMarkData->GetMarkedRowSpans(GetViewData()->GetTabNo(), aMarkedRows); + if (aMarkedRows.empty()) { - pRanges[0] = pRanges[1] = GetViewData()->GetCurY(); - nRangeCnt = 1; + SCROW nCurRow = GetViewData()->GetCurY(); + aMarkedRows.push_back(sc::RowSpan(nCurRow, nCurRow)); } double nPPTX = GetViewData()->GetPPTX(); @@ -133,26 +134,25 @@ sal_Bool ScViewFunc::AdjustBlockHeight( sal_Bool bPaint, ScMarkData* pMarkData ) for (; itr != itrEnd; ++itr) { SCTAB nTab = *itr; - SCCOLROW* pOneRange = pRanges; - sal_Bool bChanged = false; + bool bChanged = false; SCROW nPaintY = 0; - for (SCROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++) + std::vector<sc::RowSpan>::const_iterator itRows = aMarkedRows.begin(), itRowsEnd = aMarkedRows.end(); + for (; itRows != itRowsEnd; ++itRows) { - SCROW nStartNo = *(pOneRange++); - SCROW nEndNo = *(pOneRange++); + SCROW nStartNo = itRows->mnRow1; + SCROW nEndNo = itRows->mnRow2; if (pDoc->SetOptimalHeight( nStartNo, nEndNo, nTab, 0, aProv.GetDevice(), nPPTX, nPPTY, aZoomX, aZoomY, false )) { if (!bChanged) nPaintY = nStartNo; - bAnyChanged = bChanged = sal_True; + bAnyChanged = bChanged = true; } } if ( bPaint && bChanged ) pDocSh->PostPaint( 0, nPaintY, nTab, MAXCOL, MAXROW, nTab, PAINT_GRID | PAINT_LEFT ); } - delete[] pRanges; if ( bPaint && bAnyChanged ) pDocSh->UpdateOle(GetViewData()); diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 089024a8d50d..b96752606c46 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -2905,7 +2905,7 @@ void ScViewFunc::UpdateSelectionArea( const ScMarkData& rSel, ScPatternAttr* pAt PAINT_GRID, nExtFlags | SC_PF_TESTMERGE ); ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); pTabViewShell->CellContentChanged(); - pTabViewShell->AdjustBlockHeight(true, const_cast<ScMarkData*>(&rSel)); + pTabViewShell->AdjustBlockHeight(false, const_cast<ScMarkData*>(&rSel)); } |