summaryrefslogtreecommitdiff
path: root/sc/source/filter/xml/XMLStylesExportHelper.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2010-11-30 23:26:34 -0500
committerKohei Yoshida <kyoshida@novell.com>2010-12-02 16:06:51 -0500
commitcf687f01ebcf5123c087c70a78b556893badd8ab (patch)
tree75b2d8300e2857614de67ca62e3bf58c83b6c88a /sc/source/filter/xml/XMLStylesExportHelper.cxx
parent09174637e0cc51142f909420531ee5d161ee0885 (diff)
Replaced the inner vector with flat_segment_tree.
This dramatically reduced memory footprint per sheet during export to ods. With my test doc with 293 sheets, the resident memory size dropped from 1.4 GB to 270 MB.
Diffstat (limited to 'sc/source/filter/xml/XMLStylesExportHelper.cxx')
-rw-r--r--sc/source/filter/xml/XMLStylesExportHelper.cxx36
1 files changed, 13 insertions, 23 deletions
diff --git a/sc/source/filter/xml/XMLStylesExportHelper.cxx b/sc/source/filter/xml/XMLStylesExportHelper.cxx
index 2745b0ce536b..144e6b5f7346 100644
--- a/sc/source/filter/xml/XMLStylesExportHelper.cxx
+++ b/sc/source/filter/xml/XMLStylesExportHelper.cxx
@@ -1218,28 +1218,29 @@ void ScRowStyles::AddNewTable(const sal_Int32 nTable, const sal_Int32 nFields)
if (nTable > nSize)
for (sal_Int32 i = nSize; i < nTable; ++i)
{
- aTables.push_back(new ScMysalInt32Vec(nFields + 1, -1));
+ aTables.push_back(new StylesType(0, nFields+1, -1));
}
}
sal_Int32 ScRowStyles::GetStyleNameIndex(const sal_Int32 nTable, const sal_Int32 nField)
{
DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
- if (static_cast<size_t>(nField) < aTables[nTable].size())
- return aTables[nTable][nField];
- else
- return aTables[nTable][aTables[nTable].size() - 1];
+ StylesType& r = aTables[nTable];
+ if (!r.is_tree_valid())
+ r.build_tree();
+ sal_Int32 nStyle;
+ if (r.search_tree(nField, nStyle))
+ return nStyle;
+
+ return -1;
}
void ScRowStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nField,
const sal_Int32 nStringIndex)
{
DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
- DBG_ASSERT(aTables[nTable].size() >= static_cast<size_t>(nField), "wrong field");
- if (aTables[nTable].size() == static_cast<size_t>(nField))
- aTables[nTable].push_back(nStringIndex);
- else
- aTables[nTable][nField] = nStringIndex;
+ StylesType& r = aTables[nTable];
+ r.insert_back(nField, nField+1, nStringIndex);
}
void ScRowStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nStartField,
@@ -1247,19 +1248,8 @@ void ScRowStyles::AddFieldStyleName(const sal_Int32 nTable, const sal_Int32 nSta
{
DBG_ASSERT( nStartField <= nEndField, "bad field range");
DBG_ASSERT(static_cast<size_t>(nTable) < aTables.size(), "wrong table");
- DBG_ASSERT(aTables[nTable].size() >= static_cast<size_t>(nStartField), "wrong field");
- ScMysalInt32Vec& rTable = aTables[nTable];
- size_t nSize = rTable.size();
- if (nSize == static_cast<size_t>(nStartField))
- rTable.insert( rTable.end(), static_cast<size_t>(nEndField - nStartField + 1), nStringIndex);
- else
- {
- size_t nField = static_cast<size_t>(nStartField);
- for ( ; nField < nSize && nField <= static_cast<size_t>(nEndField); ++nField)
- rTable[nField] = nStringIndex;
- if (nField <= static_cast<size_t>(nEndField))
- rTable.insert( rTable.end(), static_cast<size_t>(nEndField - nField + 1), nStringIndex);
- }
+ StylesType& r = aTables[nTable];
+ r.insert_back(nStartField, nEndField+1, nStringIndex);
}
rtl::OUString* ScRowStyles::GetStyleName(const sal_Int32 nTable, const sal_Int32 nField)