diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-04-26 10:49:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-04-26 15:47:10 +0200 |
commit | 3bd65f0e3ea9953c7f4b00f3d42171d9b3dc3fd0 (patch) | |
tree | b0bbfb9a571651aee84e374eb24b53649260b99d /vcl/source | |
parent | 8d2a340eb8a4b6f51e2a121caba3a0d3b47504f2 (diff) |
tdf#108757 speed up PDF generation
std::list->std::vector reduces output time by 10% because we search the
m_aChildren often and vector is better at that
Change-Id: I4d0d5f6248a9c36aa0085cb22315ad6e2f53738e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151041
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 2e2788fbac8b..98a1221676f2 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -10728,7 +10728,7 @@ sal_Int32 PDFWriterImpl::beginStructureElement( PDFWriter::StructElement eType, // silently insert structure into document again if one properly exists if( ! m_aStructure[ 0 ].m_aChildren.empty() ) { - const std::list< sal_Int32 >& rRootChildren = m_aStructure[0].m_aChildren; + const std::vector< sal_Int32 >& rRootChildren = m_aStructure[0].m_aChildren; auto it = std::find_if(rRootChildren.begin(), rRootChildren.end(), [&](sal_Int32 nElement) { return m_aStructure[ nElement ].m_eType == PDFWriter::Document; }); if( it != rRootChildren.end() ) @@ -10889,7 +10889,7 @@ void PDFWriterImpl::addInternalStructureContainer( PDFStructureElement& rEle ) //then we need to add the containers for the kids elements // a list to be used for the new kid element std::list< PDFStructureElementKid > aNewKids; - std::list< sal_Int32 > aNewChildren; + std::vector< sal_Int32 > aNewChildren; // add Div in RoleMap, in case no one else did (TODO: is it needed? Is it dangerous?) OString aAliasName("Div"); @@ -10912,7 +10912,7 @@ void PDFWriterImpl::addInternalStructureContainer( PDFStructureElement& rEle ) aNewKids.emplace_back( rEleNew.m_nObject ); aNewChildren.push_back( nNewId ); - std::list< sal_Int32 >::iterator aChildEndIt( rEle.m_aChildren.begin() ); + std::vector< sal_Int32 >::iterator aChildEndIt( rEle.m_aChildren.begin() ); std::list< PDFStructureElementKid >::iterator aKidEndIt( rEle.m_aKids.begin() ); advance( aChildEndIt, ncMaxPDFArraySize ); advance( aKidEndIt, ncMaxPDFArraySize ); @@ -10921,10 +10921,11 @@ void PDFWriterImpl::addInternalStructureContainer( PDFStructureElement& rEle ) rEle.m_aKids, rEle.m_aKids.begin(), aKidEndIt ); - rEleNew.m_aChildren.splice( rEleNew.m_aChildren.begin(), - rEle.m_aChildren, + rEleNew.m_aChildren.insert( rEleNew.m_aChildren.begin(), rEle.m_aChildren.begin(), aChildEndIt ); + rEle.m_aChildren.erase( rEle.m_aChildren.begin(), aChildEndIt ); + // set the kid's new parent for (auto const& child : rEleNew.m_aChildren) { |