unotools/source/misc/fontdefs.cxx | 10 +++++----- vcl/inc/pdf/pdfwriter_impl.hxx | 2 +- vcl/source/gdi/pdfwriter_impl.cxx | 11 ++++++----- 3 files changed, 12 insertions(+), 11 deletions(-)
New commits: commit 3bd65f0e3ea9953c7f4b00f3d42171d9b3dc3fd0 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Apr 26 10:49:42 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Apr 26 15:47:10 2023 +0200 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.gran...@collabora.co.uk> 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) { commit 8d2a340eb8a4b6f51e2a121caba3a0d3b47504f2 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Apr 26 10:48:22 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Apr 26 15:47:02 2023 +0200 tdf#108757 avoid some OUString construction on a hot path Change-Id: I468bc9fac024dd9fa33286382264e2b84617481b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151040 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/unotools/source/misc/fontdefs.cxx b/unotools/source/misc/fontdefs.cxx index 3ec1226a289d..b1cca8fe6469 100644 --- a/unotools/source/misc/fontdefs.cxx +++ b/unotools/source/misc/fontdefs.cxx @@ -18,6 +18,7 @@ */ #include <o3tl/safeint.hxx> +#include <o3tl/string_view.hxx> #include <unotools/fontdefs.hxx> #include <unotools/fontcfg.hxx> #include <rtl/ustrbuf.hxx> @@ -509,11 +510,10 @@ std::u16string_view GetNextFontToken( std::u16string_view rTokenStr, sal_Int32& static bool ImplIsFontToken( std::u16string_view rName, std::u16string_view rToken ) { - OUString aTempName; sal_Int32 nIndex = 0; do { - aTempName = GetNextFontToken( rName, nIndex ); + std::u16string_view aTempName = GetNextFontToken( rName, nIndex ); if ( rToken == aTempName ) return true; } @@ -572,9 +572,9 @@ OUString GetSubsFontName( std::u16string_view rName, SubsFontFlags nFlags ) bool IsOpenSymbol(std::u16string_view rFontName) { sal_Int32 nIndex = 0; - OUString sFamilyNm(GetNextFontToken(rFontName, nIndex)); - return (sFamilyNm.equalsIgnoreAsciiCase("starsymbol") || - sFamilyNm.equalsIgnoreAsciiCase("opensymbol")); + std::u16string_view sFamilyNm(GetNextFontToken(rFontName, nIndex)); + return (o3tl::equalsIgnoreAsciiCase(sFamilyNm, "starsymbol") || + o3tl::equalsIgnoreAsciiCase(sFamilyNm, "opensymbol")); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */