include/svtools/grfmgr.hxx | 6 +++--- svtools/source/graphic/grfcache.cxx | 4 ++-- svtools/source/graphic/grfmgr2.cxx | 20 ++++++++------------ 3 files changed, 13 insertions(+), 17 deletions(-)
New commits: commit fdc867a4bc6ac2810732af898c620a889cde725c Author: Aron Budea <ba...@caesar.elte.hu> Date: Sun Aug 28 18:42:31 2016 +0200 tdf#100442 use unordered_set for GraphicManager's maObjList Speeds up ImplCheckSizeOfSwappedInGraphics. maObjList didn't seem to depend on it being a vector. Change-Id: I0028186b5c4f53ae198b9b33a31c51f0b2e5eb45 Reviewed-on: https://gerrit.libreoffice.org/28439 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Michael Meeks <michael.me...@collabora.com> Tested-by: Michael Meeks <michael.me...@collabora.com> diff --git a/include/svtools/grfmgr.hxx b/include/svtools/grfmgr.hxx index 80e03d0..f30b0df 100644 --- a/include/svtools/grfmgr.hxx +++ b/include/svtools/grfmgr.hxx @@ -24,6 +24,8 @@ #include <svtools/svtdllapi.h> #include <o3tl/typed_flags_set.hxx> +#include <unordered_set> + enum class GraphicManagerDrawFlags { CACHED = 0x01, @@ -504,8 +506,6 @@ public: sal_uLong GetDataChangeTimeStamp() const { return mnDataChangeTimeStamp; } }; -typedef ::std::vector< GraphicObject* > GraphicObjectList_impl; - class SVT_DLLPUBLIC GraphicManager { friend class GraphicObject; @@ -513,7 +513,7 @@ class SVT_DLLPUBLIC GraphicManager private: - GraphicObjectList_impl maObjList; + std::unordered_set< GraphicObject* > maObjList; sal_uLong mnUsedSize; // currently used memory footprint of all swapped in graphics GraphicCache* mpCache; diff --git a/svtools/source/graphic/grfcache.cxx b/svtools/source/graphic/grfcache.cxx index 5d2bf62..4669f21 100644 --- a/svtools/source/graphic/grfcache.cxx +++ b/svtools/source/graphic/grfcache.cxx @@ -146,7 +146,7 @@ class GraphicCacheEntry { private: - GraphicObjectList_impl maGraphicObjectList; + std::vector< GraphicObject* > maGraphicObjectList; GraphicID maID; GfxLink maGfxLink; @@ -336,7 +336,7 @@ void GraphicCacheEntry::AddGraphicObjectReference( const GraphicObject& rObj, Gr bool GraphicCacheEntry::ReleaseGraphicObjectReference( const GraphicObject& rObj ) { for( - GraphicObjectList_impl::iterator it = maGraphicObjectList.begin(); + auto it = maGraphicObjectList.begin(); it != maGraphicObjectList.end(); ++it ) { diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx index 03ca1a5..6455884 100644 --- a/svtools/source/graphic/grfmgr2.cxx +++ b/svtools/source/graphic/grfmgr2.cxx @@ -141,10 +141,10 @@ bool GraphicManager::DrawObj( OutputDevice* pOut, const Point& rPt, const Size& void GraphicManager::ImplRegisterObj( const GraphicObject& rObj, Graphic& rSubstitute, const OString* pID, const GraphicObject* pCopyObj ) { - assert(std::find(maObjList.begin(), maObjList.end(), - const_cast<GraphicObject*>(&rObj)) == maObjList.end()); + assert(maObjList.find(const_cast<GraphicObject*>(&rObj)) == maObjList.end()); + + maObjList.emplace( const_cast<GraphicObject*>(&rObj) ); - maObjList.push_back( const_cast<GraphicObject*>(&rObj) ); mpCache->AddGraphicObject( rObj, rSubstitute, pID, pCopyObj ); if( !rObj.IsSwappedOut() ) mnUsedSize += rObj.maGraphic.GetSizeBytes(); @@ -158,13 +158,9 @@ void GraphicManager::ImplUnregisterObj( const GraphicObject& rObj ) assert(mnUsedSize >= rObj.maGraphic.GetSizeBytes()); mnUsedSize -= rObj.maGraphic.GetSizeBytes(); } - for( GraphicObjectList_impl::iterator it = maObjList.begin(); it != maObjList.end(); ++it ) - { - if ( *it == &rObj ) { - maObjList.erase( it ); - return; - } - } + if ( 0 < maObjList.erase( const_cast<GraphicObject*>(&rObj) ) ) + return; + assert(false); // surely it should have been registered? } @@ -203,7 +199,7 @@ void GraphicManager::ImplCheckSizeOfSwappedInGraphics(const GraphicObject* pGrap std::vector< GraphicObject* > aCandidates(maObjList.begin(), maObjList.end()); // if we use more currently, sort by last DataChangeTimeStamp // sort by DataChangeTimeStamp so that the oldest get removed first - ::std::sort(aCandidates.begin(), aCandidates.end(), simpleSortByDataChangeTimeStamp()); + std::sort(aCandidates.begin(), aCandidates.end(), simpleSortByDataChangeTimeStamp()); for(sal_uInt32 a(0); mnUsedSize >= nMaxCacheSize && a < aCandidates.size(); a++) { @@ -214,7 +210,7 @@ void GraphicManager::ImplCheckSizeOfSwappedInGraphics(const GraphicObject* pGrap { continue; } - if (std::find(maObjList.begin(), maObjList.end(), pObj) == maObjList.end()) + if (maObjList.find(pObj) == maObjList.end()) { // object has been deleted when swapping out another one continue; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits