[Libreoffice-commits] core.git: 2 commits - lotuswordpro/inc lotuswordpro/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Fri Aug 27 20:53:47 UTC 2021
lotuswordpro/inc/xfilter/xfrow.hxx | 13 ++-----------
lotuswordpro/source/filter/lwptablelayout.cxx | 8 ++------
lotuswordpro/source/filter/xfilter/xfrow.cxx | 22 ++++++++++++----------
3 files changed, 16 insertions(+), 27 deletions(-)
New commits:
commit b513ecce3e00e512947cd2d9fd61d1b80ba0d4bb
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Aug 27 20:13:18 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Aug 27 22:53:26 2021 +0200
Related: ofz#27296 OOM std::map->std::vector
dbgutil massif peak of 3.1G -> 2.7G
GB
3.117^ #
| :::::::::::::::::::::::#
| ::::: #
| :@::::: #:
| :::@::::: #:
| :::::@::::: #:
| :::::::@::::: #::
| :::::::::@::::: #:@
| ::::::::::@::::: #:@:
| :::::::::::::@::::: #:@:
| :::::::::::::::@::::: #:@::
| :::::::::::::::::@::::: #:@::
| ::::::::::::::::::@::::: #:@::
| ::::::::::::::::::::@::::: #:@::@
| @:::::::::::::::::::::@::::: #:@::@
| @::@:::::::::::::::::::::@::::: #:@::@:
| ::@::@:::::::::::::::::::::@::::: #:@::@:
| @:::@::@:::::::::::::::::::::@::::: #:@::@:
| ::@:::@::@:::::::::::::::::::::@::::: #:@::@::
| ::::@:::@::@:::::::::::::::::::::@::::: #:@::@::
0 +----------------------------------------------------------------------->Gi
0 116.7
--->
GB
2.718^ :
| @######:
| @@@# :::
| @@@@# ::::
| @@@@@@@# :::::
| @@@ @@@@# ::::::
| :@@@@ @@@@# :::::::
| @::@@@@ @@@@# :::::::@:
| @@@::@@@@ @@@@# :::::::@::
| @@@@::@@@@ @@@@# :::::::@:::
| @@@@@@::@@@@ @@@@# :::::::@::::
| ::@@@@@@::@@@@ @@@@# :::::::@::::::
| @::@@@@@@::@@@@ @@@@# :::::::@:::::@:
| @@@::@@@@@@::@@@@ @@@@# :::::::@:::::@::
| @@@@@::@@@@@@::@@@@ @@@@# :::::::@:::::@:::
| @@@@@@@::@@@@@@::@@@@ @@@@# :::::::@:::::@::::
| @@@@@@@@@::@@@@@@::@@@@ @@@@# :::::::@:::::@:::::
| @ @@@@@@@::@@@@@@::@@@@ @@@@# :::::::@:::::@::::::@
| :@@@ @@@@@@@::@@@@@@::@@@@ @@@@# :::::::@:::::@::::::@:
| @@:@ @ @@@@@@@::@@@@@@::@@@@ @@@@# :::::::@:::::@::::::@::
0 +----------------------------------------------------------------------->Gi
0 34.29
Change-Id: Id56615e554d07a76a6a87476a40cc6190c0555da
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121181
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/lotuswordpro/inc/xfilter/xfrow.hxx b/lotuswordpro/inc/xfilter/xfrow.hxx
index f18e12b8c64b..3f419b3dfdc1 100644
--- a/lotuswordpro/inc/xfilter/xfrow.hxx
+++ b/lotuswordpro/inc/xfilter/xfrow.hxx
@@ -94,7 +94,7 @@ public:
private:
XFTable *m_pOwnerTable;
- std::map<sal_Int32, rtl::Reference<XFCell>> m_aCells;
+ std::vector<rtl::Reference<XFCell>> m_aCells;
sal_Int32 m_nRepeat;
sal_Int32 m_nRow;
};
diff --git a/lotuswordpro/source/filter/xfilter/xfrow.cxx b/lotuswordpro/source/filter/xfilter/xfrow.cxx
index d4825f966aff..1bdfb8849a05 100644
--- a/lotuswordpro/source/filter/xfilter/xfrow.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfrow.cxx
@@ -80,10 +80,10 @@ void XFRow::AddCell(rtl::Reference<XFCell> const & rCell)
{
if (!rCell)
return;
- sal_Int32 col = m_aCells.size()+1;
+ sal_Int32 col = m_aCells.size() + 1;
rCell->SetCol(col);
rCell->SetOwnerRow(this);
- m_aCells[col] = rCell;
+ m_aCells.push_back(rCell);
}
sal_Int32 XFRow::GetCellCount() const
@@ -91,12 +91,14 @@ sal_Int32 XFRow::GetCellCount() const
return m_aCells.size();
}
+// 1 based
XFCell* XFRow::GetCell(sal_Int32 col) const
{
- if( m_aCells.find(col) == m_aCells.end() )
- return nullptr;
- else
- return m_aCells.find(col)->second.get();
+ assert(col > 0);
+ size_t nIndex = col - 1;
+ if (nIndex < m_aCells.size())
+ return m_aCells[nIndex].get();
+ return nullptr;
}
void XFRow::ToXml(IXFStream *pStrm)
@@ -111,12 +113,12 @@ void XFRow::ToXml(IXFStream *pStrm)
pAttrList->AddAttribute( "table:number-rows-repeated", OUString::number(m_nRepeat) );
pStrm->StartElement( "table:table-row" );
- for (auto const& cell : m_aCells)
+ for (size_t nIndex = 0, nCount = m_aCells.size(); nIndex < nCount; ++nIndex)
{
- int col = cell.first;
- XFCell *pCell = cell.second.get();
- if( !pCell )
+ XFCell *pCell = m_aCells[nIndex].get();
+ if (!pCell)
continue;
+ int col = nIndex + 1;
if( col>lastCol+1 )
{
XFCell *pNULLCell = new XFCell();
commit a7667f53c23bc88ed645f84a19896bc45f748f2a
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Aug 27 20:01:33 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Aug 27 22:53:13 2021 +0200
we are going to remove the entire row anyway
so don't iterate over the cells explicitly dropping them
Change-Id: If0de504ac9711d1e6a757cdd15574f15585ca928
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121180
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/lotuswordpro/inc/xfilter/xfrow.hxx b/lotuswordpro/inc/xfilter/xfrow.hxx
index 009bdad95326..f18e12b8c64b 100644
--- a/lotuswordpro/inc/xfilter/xfrow.hxx
+++ b/lotuswordpro/inc/xfilter/xfrow.hxx
@@ -57,8 +57,7 @@
* @file
* Table row object. A table is consist by rows.
************************************************************************/
-#ifndef INCLUDED_LOTUSWORDPRO_INC_XFILTER_XFROW_HXX
-#define INCLUDED_LOTUSWORDPRO_INC_XFILTER_XFROW_HXX
+#pragma once
#include <xfilter/xfcell.hxx>
#include <xfilter/xfcontent.hxx>
@@ -93,8 +92,6 @@ public:
virtual void ToXml(IXFStream *pStrm) override;
- void RemoveCell(sal_Int32 cell);
-
private:
XFTable *m_pOwnerTable;
std::map<sal_Int32, rtl::Reference<XFCell>> m_aCells;
@@ -127,10 +124,4 @@ inline XFTable* XFRow::GetOwnerTable()
return m_pOwnerTable;
}
-inline void XFRow::RemoveCell(sal_Int32 cell)
-{
- m_aCells.erase(cell);
-}
-
-#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx
index 4f2c4c8d30ca..2a72e1155cb0 100644
--- a/lotuswordpro/source/filter/lwptablelayout.cxx
+++ b/lotuswordpro/source/filter/lwptablelayout.cxx
@@ -942,12 +942,11 @@ void LwpTableLayout::SplitRowToCells(XFTable* pTmpTable, rtl::Reference<XFTable>
rtl::Reference<XFCell> xXFCell2(new XFCell);
rtl::Reference<XFTable> xSubTable1(new XFTable);
rtl::Reference<XFTable> xSubTable2(new XFTable);
- XFRow* pOldRow;
rtl::Reference<XFCell> xNewCell;
for (i=1;i<=nRowNum;i++)
{
- pOldRow = pTmpTable->GetRow(i);
+ XFRow* pOldRow = pTmpTable->GetRow(i);
rtl::Reference<XFRow> xNewRow(new XFRow);
xNewRow->SetStyleName(pOldRow->GetStyleName());
for (sal_uInt8 j=1;j<=pCellMark[i];j++)
@@ -965,7 +964,7 @@ void LwpTableLayout::SplitRowToCells(XFTable* pTmpTable, rtl::Reference<XFTable>
for (i=1;i<=nRowNum;i++)
{
- pOldRow = pTmpTable->GetRow(i);
+ XFRow* pOldRow = pTmpTable->GetRow(i);
rtl::Reference<XFRow> xNewRow(new XFRow);
xNewRow->SetStyleName(pOldRow->GetStyleName());
for(sal_Int32 j=pCellMark[i]+1;j<=pOldRow->GetCellCount();j++)
@@ -986,9 +985,6 @@ void LwpTableLayout::SplitRowToCells(XFTable* pTmpTable, rtl::Reference<XFTable>
//remove tmp table
for (i=1;i<=nRowNum;i++)
{
- pOldRow = pTmpTable->GetRow(i);
- for(sal_Int32 j=1;j<=pOldRow->GetCellCount();j++)
- pOldRow->RemoveCell(j);
pTmpTable->RemoveRow(i);
}
}
More information about the Libreoffice-commits
mailing list