From 21b1d5b52ecbbff394a55daef5eb74ad042e5be7 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Wed, 7 Aug 2019 21:21:36 -0500 Subject: [PATCH] Hotspot elimination. --- indra/newview/llhudnametag.cpp | 14 +++++++------- indra/newview/llhudnametag.h | 4 ++-- indra/newview/llhudtext.cpp | 14 +++++++------- indra/newview/llhudtext.h | 4 ++-- indra/newview/llspatialpartition.cpp | 1 + indra/newview/llviewertexturelist.cpp | 16 ++++++++++------ indra/newview/llviewertexturelist.h | 3 +++ 7 files changed, 32 insertions(+), 24 deletions(-) diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp index c80f1818e..d57ae3006 100644 --- a/indra/newview/llhudnametag.cpp +++ b/indra/newview/llhudnametag.cpp @@ -1056,15 +1056,15 @@ void LLHUDNameTag::reshape() F32 LLHUDNameTag::LLHUDTextSegment::getWidth(const LLFontGL* font) { - std::map::iterator iter = mFontWidthMap.find(font); - if (iter != mFontWidthMap.end()) + if (mFontWidthMap[0].first == font) { - return iter->second; + return mFontWidthMap[0].second; } - else + else if (mFontWidthMap[1].first == font) { - F32 width = font->getWidthF32(mText.c_str()); - mFontWidthMap[font] = width; - return width; + return mFontWidthMap[1].second; } + F32 width = font->getWidthF32(mText.c_str()); + mFontWidthMap[mFontWidthMap[0].first != nullptr] = std::make_pair(font, width); + return width; } diff --git a/indra/newview/llhudnametag.h b/indra/newview/llhudnametag.h index e238fac5a..bc48d788e 100644 --- a/indra/newview/llhudnametag.h +++ b/indra/newview/llhudnametag.h @@ -63,14 +63,14 @@ protected: {} F32 getWidth(const LLFontGL* font); const LLWString& getText() const { return mText; } - void clearFontWidthMap() { mFontWidthMap.clear(); } + void clearFontWidthMap() { mFontWidthMap[0].first = nullptr; mFontWidthMap[1].first = nullptr; } LLColor4 mColor; LLFontGL::StyleFlags mStyle; const LLFontGL* mFont; private: LLWString mText; - std::map mFontWidthMap; + std::pair mFontWidthMap[2]; }; public: diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp index c996c462e..f20a4cca3 100644 --- a/indra/newview/llhudtext.cpp +++ b/indra/newview/llhudtext.cpp @@ -674,17 +674,17 @@ void LLHUDText::reshape() F32 LLHUDText::LLHUDTextSegment::getWidth(const LLFontGL* font) { - std::map::iterator iter = mFontWidthMap.find(font); - if (iter != mFontWidthMap.end()) + if (mFontWidthMap[0].first == font) { - return iter->second; + return mFontWidthMap[0].second; } - else + else if (mFontWidthMap[1].first == font) { - F32 width = font->getWidthF32(mText.c_str()); - mFontWidthMap[font] = width; - return width; + return mFontWidthMap[1].second; } + F32 width = font->getWidthF32(mText.c_str()); + mFontWidthMap[mFontWidthMap[0].first != nullptr] = std::make_pair(font, width); + return width; } // [RLVa:KB] - Checked: 2010-03-27 (RLVa-1.4.0a) | Added: RLVa-1.0.0f diff --git a/indra/newview/llhudtext.h b/indra/newview/llhudtext.h index 68450753c..9ee224954 100644 --- a/indra/newview/llhudtext.h +++ b/indra/newview/llhudtext.h @@ -61,14 +61,14 @@ protected: {} F32 getWidth(const LLFontGL* font); const LLWString& getText() const { return mText; } - void clearFontWidthMap() { mFontWidthMap.clear(); } + void clearFontWidthMap() { mFontWidthMap[0].first = nullptr; mFontWidthMap[1].first = nullptr; } LLColor4 mColor; LLFontGL::StyleFlags mStyle; const LLFontGL* mFont; private: LLWString mText; - std::map mFontWidthMap; + std::pair mFontWidthMap[2]; }; public: diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index a62b1166b..3f9a4ef0b 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -1269,6 +1269,7 @@ public: group->destroyGL(); {OctreeGuard guard(group->getOctreeNode()); + if (!mNoRebuild) // Singu note: No need to iterate if not rebuilding... for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i) { LLDrawable* drawable = (LLDrawable*)(*i)->getDrawable(); diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index d49210b6d..82d4cef61 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -326,6 +326,7 @@ void LLViewerTextureList::shutdown() mCreateTextureList.clear(); mUUIDMap.clear(); + mUUIDDict.clear(); mImageList.clear(); @@ -600,8 +601,8 @@ LLViewerFetchedTexture* LLViewerTextureList::createImage(const LLUUID &image_id, LLViewerFetchedTexture *LLViewerTextureList::findImage(const LLUUID &image_id) { - uuid_map_t::iterator iter = mUUIDMap.find(image_id); - if(iter == mUUIDMap.end()) + auto& iter = mUUIDDict.find(image_id); + if(iter == mUUIDDict.end()) return NULL; return iter->second; } @@ -648,8 +649,8 @@ void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image) << " but doesn't have mInImageList set" << " ref count is " << image->getNumRefs() << LL_ENDL; - uuid_map_t::iterator iter = mUUIDMap.find(image->getID()); - if(iter == mUUIDMap.end()) + auto& iter = mUUIDDict.find(image->getID()); + if(iter == mUUIDDict.end()) { LL_INFOS() << "Image " << image->getID() << " is also not in mUUIDMap!" << LL_ENDL ; } @@ -690,7 +691,8 @@ void LLViewerTextureList::addImage(LLViewerFetchedTexture *new_image) sNumImages++; addImageToList(new_image); - mUUIDMap[image_id] = new_image; + mUUIDMap.emplace(image_id, new_image); + mUUIDDict.emplace(image_id, new_image); } @@ -703,7 +705,9 @@ void LLViewerTextureList::deleteImage(LLViewerFetchedTexture *image) mCallbackList.erase(image); } - llverify(mUUIDMap.erase(image->getID()) == 1); + const LLUUID& id = image->getID(); + llverify(mUUIDMap.erase(id) == 1); + llverify(mUUIDDict.erase(id) == 1); sNumImages--; removeImageFromList(image); } diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index b24fd8702..e69b9ddbc 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -35,6 +35,7 @@ #include "llui.h" #include #include +#include const U32 LL_IMAGE_REZ_LOSSLESS_CUTOFF = 128; @@ -187,6 +188,8 @@ public: private: typedef std::map< LLUUID, LLPointer > uuid_map_t; uuid_map_t mUUIDMap; + typedef std::unordered_map< LLUUID, LLPointer* > uuid_dict_t; + uuid_map_t mUUIDDict; LLUUID mLastUpdateUUID; LLUUID mLastFetchUUID;