diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-05-16 18:37:12 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-05-20 20:13:08 -0400 |
commit | 8eed8f8c3d6a58d28f8af5e5688d8fe8756d7dc8 (patch) | |
tree | c48bde79961d86efab1e97355e2d000225342b96 /sc/source/core/data/columnspanset.cxx | |
parent | 4da9bf8086c90f0b0b4394cd6578da1405ca3e8d (diff) |
Optimize ScViewFunc::GetSelectionScriptType().
This change reduces the duration of this method from somewhere in the
ballpark of 10 seconds down to a tiny fraction of a second.
Change-Id: I0278dc06a4f134b43cd08bd94693b6dec4893f1f
Diffstat (limited to 'sc/source/core/data/columnspanset.cxx')
-rw-r--r-- | sc/source/core/data/columnspanset.cxx | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/sc/source/core/data/columnspanset.cxx b/sc/source/core/data/columnspanset.cxx index de785395e4c0..ea4f7060dbc6 100644 --- a/sc/source/core/data/columnspanset.cxx +++ b/sc/source/core/data/columnspanset.cxx @@ -15,6 +15,7 @@ namespace sc { ColumnSpanSet::Action::~Action() {} +void ColumnSpanSet::Action::startColumn(SCTAB /*nTab*/, SCCOL /*nCol*/) {} ColumnSpanSet::~ColumnSpanSet() { @@ -30,11 +31,8 @@ ColumnSpanSet::~ColumnSpanSet() } } -void ColumnSpanSet::set(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bVal) +ColumnSpanSet::ColumnSpansType& ColumnSpanSet::getColumnSpans(SCTAB nTab, SCCOL nCol) { - if (!ValidTab(nTab) || !ValidCol(nCol) || !ValidRow(nRow)) - return; - if (static_cast<size_t>(nTab) >= maDoc.size()) maDoc.resize(nTab+1, NULL); @@ -48,10 +46,27 @@ void ColumnSpanSet::set(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bVal) if (!rTab[nCol]) rTab[nCol] = new ColumnSpansType(0, MAXROW+1, false); - ColumnSpansType& rCol = *rTab[nCol]; + return *rTab[nCol]; +} + +void ColumnSpanSet::set(SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal) +{ + if (!ValidTab(nTab) || !ValidCol(nCol) || !ValidRow(nRow)) + return; + + ColumnSpansType& rCol = getColumnSpans(nTab, nCol); rCol.insert_back(nRow, nRow+1, bVal); } +void ColumnSpanSet::set(SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool bVal) +{ + if (!ValidTab(nTab) || !ValidCol(nCol) || !ValidRow(nRow1) || !ValidRow(nRow2)) + return; + + ColumnSpansType& rCol = getColumnSpans(nTab, nCol); + rCol.insert_back(nRow1, nRow2+1, bVal); +} + void ColumnSpanSet::executeFromTop(Action& ac) const { for (size_t nTab = 0; nTab < maDoc.size(); ++nTab) @@ -65,6 +80,7 @@ void ColumnSpanSet::executeFromTop(Action& ac) const if (!rTab[nCol]) continue; + ac.startColumn(nTab, nCol); ColumnSpansType& rCol = *rTab[nCol]; ColumnSpansType::const_iterator it = rCol.begin(), itEnd = rCol.end(); SCROW nRow1, nRow2; @@ -94,6 +110,7 @@ void ColumnSpanSet::executeFromBottom(Action& ac) const if (!rTab[nCol]) continue; + ac.startColumn(nTab, nCol); ColumnSpansType& rCol = *rTab[nCol]; ColumnSpansType::const_reverse_iterator it = rCol.rbegin(), itEnd = rCol.rend(); SCROW nRow1, nRow2; |