From 77f8855fd6bc04ac150f7892115f57b1de0f9737 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Mon, 7 Oct 2019 12:07:00 -0400 Subject: [PATCH] Swap to absl hash maps on two extremely hot paths --- indra/newview/llmeshrepository.cpp | 6 +++--- indra/newview/llmeshrepository.h | 4 +++- indra/newview/llviewerobjectlist.cpp | 8 ++++---- indra/newview/llviewerobjectlist.h | 14 ++++++++------ 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 44599742d..4d2ea0251 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -2685,7 +2685,7 @@ void LLMeshRepository::notifyLoadedMeshes() void LLMeshRepository::notifySkinInfoReceived(LLMeshSkinInfo& info) { - mSkinMap[info.mMeshID] = info; + mSkinMap.insert_or_assign(info.mMeshID, info); skin_load_map::iterator iter = mLoadingSkins.find(info.mMeshID); if (iter != mLoadingSkins.end()) @@ -2792,8 +2792,8 @@ const LLMeshSkinInfo* LLMeshRepository::getSkinInfo(const LLUUID& mesh_id, const { if (mesh_id.notNull()) { - skin_map::iterator iter = mSkinMap.find(mesh_id); - if (iter != mSkinMap.end()) + const auto iter = mSkinMap.find(mesh_id); + if (iter != mSkinMap.cend()) { return &(iter->second); } diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index 62666bc65..6931cd3df 100644 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -39,6 +39,8 @@ #include "lluploadfloaterobservers.h" #include "aistatemachinethread.h" +#include + #ifndef BOOST_FUNCTION_HPP_INCLUDED #include #define BOOST_FUNCTION_HPP_INCLUDED @@ -561,7 +563,7 @@ public: typedef std::map > mesh_load_map; mesh_load_map mLoadingMeshes[4]; - typedef boost::unordered_map skin_map; + typedef absl::node_hash_map skin_map; skin_map mSkinMap; typedef std::map decomposition_map; diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index f0ca03ab7..42f9f5083 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -2002,13 +2002,13 @@ LLViewerObject *LLViewerObjectList::createObjectViewer(const LLPCode pcode, LLVi return NULL; } - mUUIDObjectMap[fullid] = objectp; + mUUIDObjectMap.insert_or_assign(fullid, objectp); if(objectp->isAvatar()) { LLVOAvatar *pAvatar = dynamic_cast(objectp); if(pAvatar) { - mUUIDAvatarMap[fullid] = pAvatar; + mUUIDAvatarMap.insert_or_assign(fullid, pAvatar); // if (LLFloaterIMPanel* im = find_im_floater(fullid)) im->addDynamicFocus(); @@ -2052,13 +2052,13 @@ LLViewerObject *LLViewerObjectList::createObject(const LLPCode pcode, LLViewerRe regionp->addToCreatedList(local_id); } - mUUIDObjectMap[fullid] = objectp; + mUUIDObjectMap.insert_or_assign(fullid, objectp); if(objectp->isAvatar()) { LLVOAvatar *pAvatar = dynamic_cast(objectp); if(pAvatar) { - mUUIDAvatarMap[fullid] = pAvatar; + mUUIDAvatarMap.insert_or_assign(fullid, pAvatar); // if (LLFloaterIMPanel* im = find_im_floater(fullid)) im->addDynamicFocus(); diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index aa86c5c5c..6ff21d3e5 100644 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -36,6 +36,8 @@ #include #include +#include "absl/container/flat_hash_map.h" + // common includes #include "llstat.h" #include "llstring.h" @@ -219,8 +221,8 @@ public: uuid_set_t mDeadObjects; - boost::unordered_map > mUUIDObjectMap; - boost::unordered_map > mUUIDAvatarMap; + absl::flat_hash_map > mUUIDObjectMap; + absl::flat_hash_map > mUUIDAvatarMap; //set of objects that need to update their cost uuid_set_t mStaleObjectCost; @@ -272,8 +274,8 @@ extern LLViewerObjectList gObjectList; // Inlines inline LLViewerObject *LLViewerObjectList::findObject(const LLUUID &id) const { - boost::unordered_map >::const_iterator iter = mUUIDObjectMap.find(id); - if(iter != mUUIDObjectMap.end()) + auto iter = mUUIDObjectMap.find(id); + if(iter != mUUIDObjectMap.cend()) { return iter->second; } @@ -285,8 +287,8 @@ inline LLViewerObject *LLViewerObjectList::findObject(const LLUUID &id) const inline LLVOAvatar *LLViewerObjectList::findAvatar(const LLUUID &id) const { - boost::unordered_map >::const_iterator iter = mUUIDAvatarMap.find(id); - return (iter != mUUIDAvatarMap.end()) ? iter->second.get() : NULL; + auto iter = mUUIDAvatarMap.find(id); + return (iter != mUUIDAvatarMap.cend()) ? iter->second.get() : NULL; } inline LLViewerObject *LLViewerObjectList::getObject(const S32 index)