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 | |
parent | tdf#108757 avoid some OUString construction on a hot path (diff) | |
download | core-3bd65f0e3ea9953c7f4b00f3d42171d9b3dc3fd0.tar.gz core-3bd65f0e3ea9953c7f4b00f3d42171d9b3dc3fd0.zip |
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>
-rw-r--r-- | vcl/inc/pdf/pdfwriter_impl.hxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 11 |
2 files changed, 7 insertions, 6 deletions
diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx index 87a5d1387755..fc9e68afc18b 100644 --- a/vcl/inc/pdf/pdfwriter_impl.hxx +++ b/vcl/inc/pdf/pdfwriter_impl.hxx @@ -588,7 +588,7 @@ struct PDFStructureElement sal_Int32 m_nParentElement; // index into structure vector sal_Int32 m_nFirstPageObject; bool m_bOpenMCSeq; - std::list< sal_Int32 > m_aChildren; // indexes into structure vector + std::vector< sal_Int32 > m_aChildren; // indexes into structure vector std::list< PDFStructureElementKid > m_aKids; std::map<PDFWriter::StructAttribute, PDFStructureAttribute > m_aAttributes; 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) { |