From e5a14bf90bad0696478bbc1504680aae1af7c2e2 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 9 Nov 2020 09:35:25 +0000 Subject: ofz#26973 shave some time off timeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 36s -> 23s Change-Id: I28451aa17cc724910f93fe53ee1247044a7c2f5c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105474 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- filter/source/graphicfilter/icgm/actimpr.cxx | 4 +- filter/source/graphicfilter/icgm/bundles.cxx | 105 +++++++-------------------- filter/source/graphicfilter/icgm/bundles.hxx | 26 +++---- 3 files changed, 38 insertions(+), 97 deletions(-) (limited to 'filter') diff --git a/filter/source/graphicfilter/icgm/actimpr.cxx b/filter/source/graphicfilter/icgm/actimpr.cxx index 728c74b44c03..48a71609519e 100644 --- a/filter/source/graphicfilter/icgm/actimpr.cxx +++ b/filter/source/graphicfilter/icgm/actimpr.cxx @@ -363,7 +363,9 @@ void CGMImpressOutAct::ImplSetTextBundle( const uno::Reference< beans::XProperty if ( pFontEntry ) { nFontType = pFontEntry->nFontType; - aFontDescriptor.Name = OUString::createFromAscii( reinterpret_cast(pFontEntry->pFontName.get()) ); + aFontDescriptor.Name = OUString(reinterpret_cast(pFontEntry->aFontName.data()), + pFontEntry->aFontName.size(), + RTL_TEXTENCODING_ASCII_US); } aFontDescriptor.Height = sal_Int16( mpCGM->pElement->nCharacterHeight * 1.50 ); if ( nFontType & 1 ) diff --git a/filter/source/graphicfilter/icgm/bundles.cxx b/filter/source/graphicfilter/icgm/bundles.cxx index 357901ad1048..89ce93e31bcf 100644 --- a/filter/source/graphicfilter/icgm/bundles.cxx +++ b/filter/source/graphicfilter/icgm/bundles.cxx @@ -28,67 +28,20 @@ void Bundle::SetColor( sal_uInt32 nColor ) mnColor = nColor; } -FontEntry::FontEntry() : - nFontType ( 0 ) +CGMFList::CGMFList() + : nFontNameCount(0) + , nCharSetCount(0) { } -FontEntry::~FontEntry() -{ -} - -CGMFList::CGMFList() : - nFontNameCount ( 0 ), - nCharSetCount ( 0 ), - nFontsAvailable ( 0 ) -{ - aFontEntryList.clear(); -} - -CGMFList::~CGMFList() -{ - ImplDeleteList(); -} - -CGMFList& CGMFList::operator=( const CGMFList& rSource ) -{ - if (this != &rSource) - { - ImplDeleteList(); - nFontsAvailable = rSource.nFontsAvailable; - nFontNameCount = rSource.nFontNameCount; - nCharSetCount = rSource.nCharSetCount; - for (auto const & pPtr : rSource.aFontEntryList) - { - std::unique_ptr pCFontEntry(new FontEntry); - if ( pPtr->pFontName ) - { - sal_uInt32 nSize = strlen( reinterpret_cast(pPtr->pFontName.get()) ) + 1; - pCFontEntry->pFontName.reset( new sal_Int8[ nSize ] ); - memcpy( pCFontEntry->pFontName.get(), pPtr->pFontName.get(), nSize ); - } - if ( pPtr->pCharSetValue ) - { - sal_uInt32 nSize = strlen( reinterpret_cast(pPtr->pCharSetValue.get()) ) + 1; - pCFontEntry->pCharSetValue.reset( new sal_Int8[ nSize ] ); - memcpy( pCFontEntry->pCharSetValue.get(), pPtr->pCharSetValue.get(), nSize ); - } - pCFontEntry->nFontType = pPtr->nFontType; - aFontEntryList.push_back( std::move(pCFontEntry) ); - } - } - return *this; -} - FontEntry* CGMFList::GetFontEntry( sal_uInt32 nIndex ) { sal_uInt32 nInd = nIndex; if ( nInd ) nInd--; - return ( nInd < aFontEntryList.size() ) ? aFontEntryList[ nInd ].get() : nullptr; + return ( nInd < aFontEntryList.size() ) ? &aFontEntryList[nInd] : nullptr; } - static sal_Int8* ImplSearchEntry( sal_Int8* pSource, sal_Int8 const * pDest, sal_uInt32 nComp, sal_uInt32 nSize ) { while ( nComp-- >= nSize ) @@ -109,24 +62,26 @@ static sal_Int8* ImplSearchEntry( sal_Int8* pSource, sal_Int8 const * pDest, sal void CGMFList::InsertName( sal_uInt8 const * pSource, sal_uInt32 nSize ) { FontEntry* pFontEntry; - if ( nFontsAvailable == nFontNameCount ) + if (nFontNameCount == aFontEntryList.size()) { - nFontsAvailable++; - pFontEntry = new FontEntry; - aFontEntryList.push_back( std::unique_ptr(pFontEntry) ); + aFontEntryList.push_back(FontEntry()); + pFontEntry = &aFontEntryList.back(); } else { - pFontEntry = aFontEntryList[ nFontNameCount ].get(); + pFontEntry = &aFontEntryList[nFontNameCount]; } nFontNameCount++; - std::unique_ptr pBuf(new sal_Int8[ nSize ]); - memcpy( pBuf.get(), pSource, nSize ); - sal_Int8* pFound = ImplSearchEntry( pBuf.get(), reinterpret_cast("ITALIC"), nSize, 6 ); - if ( pFound ) + + if (nSize == 0) + return; + + std::vector aBuf(pSource, pSource + nSize); + sal_Int8* pFound = ImplSearchEntry(aBuf.data(), reinterpret_cast("ITALIC"), nSize, 6); + if (pFound) { pFontEntry->nFontType |= 1; - sal_uInt32 nPrev = pFound - pBuf.get(); + sal_uInt32 nPrev = pFound - aBuf.data(); sal_uInt32 nToCopyOfs = 6; if ( nPrev && ( pFound[ -1 ] == '-' || pFound[ -1 ] == ' ' ) ) { @@ -141,12 +96,12 @@ void CGMFList::InsertName( sal_uInt8 const * pSource, sal_uInt32 nSize ) } nSize -= nToCopyOfs; } - pFound = ImplSearchEntry( pBuf.get(), reinterpret_cast("BOLD"), nSize, 4 ); + pFound = ImplSearchEntry(aBuf.data(), reinterpret_cast("BOLD"), nSize, 4); if ( pFound ) { pFontEntry->nFontType |= 2; - sal_uInt32 nPrev = pFound - pBuf.get(); + sal_uInt32 nPrev = pFound - aBuf.data(); sal_uInt32 nToCopyOfs = 4; if ( nPrev && ( pFound[ -1 ] == '-' || pFound[ -1 ] == ' ' ) ) { @@ -161,35 +116,27 @@ void CGMFList::InsertName( sal_uInt8 const * pSource, sal_uInt32 nSize ) } nSize -= nToCopyOfs; } - pFontEntry->pFontName.reset( new sal_Int8[ nSize + 1 ] ); - pFontEntry->pFontName[ nSize ] = 0; - memcpy( pFontEntry->pFontName.get(), pBuf.get(), nSize ); + pFontEntry->aFontName.assign(aBuf.data(), aBuf.data() + nSize); } - void CGMFList::InsertCharSet( sal_uInt8 const * pSource, sal_uInt32 nSize ) { FontEntry* pFontEntry; - if ( nFontsAvailable == nCharSetCount ) + if (nCharSetCount == aFontEntryList.size()) { - nFontsAvailable++; - pFontEntry = new FontEntry; - aFontEntryList.push_back( std::unique_ptr(pFontEntry) ); + aFontEntryList.push_back(FontEntry()); + pFontEntry = &aFontEntryList.back(); } else { - pFontEntry = aFontEntryList[ nCharSetCount ].get(); + pFontEntry = &aFontEntryList[nCharSetCount]; } nCharSetCount++; - pFontEntry->pCharSetValue.reset( new sal_Int8[ nSize + 1 ] ); - pFontEntry->pCharSetValue[ nSize ] = 0; - memcpy( pFontEntry->pCharSetValue.get(), pSource, nSize ); -} + if (nSize == 0) + return; -void CGMFList::ImplDeleteList() -{ - aFontEntryList.clear(); + pFontEntry->aCharSetValue.assign(pSource, pSource + nSize); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/graphicfilter/icgm/bundles.hxx b/filter/source/graphicfilter/icgm/bundles.hxx index d4cd01839acc..a884937f8dae 100644 --- a/filter/source/graphicfilter/icgm/bundles.hxx +++ b/filter/source/graphicfilter/icgm/bundles.hxx @@ -138,38 +138,30 @@ public: }; -class FontEntry +struct FontEntry { -public: - std::unique_ptr - pFontName; - std::unique_ptr - pCharSetValue; + std::vector aFontName; + std::vector aCharSetValue; sal_uInt32 nFontType; // bit 0 = 1 -> Italic, // bit 1 = 1 -> Bold - - FontEntry(); - ~FontEntry(); + FontEntry() + : nFontType(0) + { + } }; class CGMFList { sal_uInt32 nFontNameCount; sal_uInt32 nCharSetCount; - ::std::vector< std::unique_ptr > - aFontEntryList; - sal_uInt32 nFontsAvailable; - - void ImplDeleteList(); + std::vector aFontEntryList; public: - CGMFList(); - ~CGMFList(); + CGMFList(); FontEntry* GetFontEntry( sal_uInt32 ); void InsertName( sal_uInt8 const * pSource, sal_uInt32 nSize ); void InsertCharSet( sal_uInt8 const * pSource, sal_uInt32 nSize ); - CGMFList& operator=( const CGMFList& rFontList ); }; #endif -- cgit