From 2c7c55b91d933e9222debaf3122e7fab41a3c52b Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Mon, 20 Jul 2020 17:26:01 -0400 Subject: [PATCH] Fix a number of hot spots from std::map with std::unordered_map --- indra/llcharacter/llkeyframemotion.h | 2 +- indra/llcharacter/llmotioncontroller.cpp | 25 ++++++++---------------- indra/llcharacter/llmotioncontroller.h | 6 ++++-- indra/llcommon/llerror.cpp | 4 ++-- indra/newview/llviewerobjectlist.cpp | 4 ++-- indra/newview/llviewerobjectlist.h | 8 ++++---- 6 files changed, 21 insertions(+), 28 deletions(-) diff --git a/indra/llcharacter/llkeyframemotion.h b/indra/llcharacter/llkeyframemotion.h index c32212db507..6f50e363daf 100644 --- a/indra/llcharacter/llkeyframemotion.h +++ b/indra/llcharacter/llkeyframemotion.h @@ -442,7 +442,7 @@ class LLKeyframeDataCache LLKeyframeDataCache(){}; ~LLKeyframeDataCache(); - typedef std::map<LLUUID, class LLKeyframeMotion::JointMotionList*> keyframe_data_map_t; + typedef boost::unordered_map<LLUUID, class LLKeyframeMotion::JointMotionList*> keyframe_data_map_t; static keyframe_data_map_t sKeyframeDataMap; static void addKeyframeData(const LLUUID& id, LLKeyframeMotion::JointMotionList*); diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp index afc5f4875e5..04bca84af89 100644 --- a/indra/llcharacter/llmotioncontroller.cpp +++ b/indra/llcharacter/llmotioncontroller.cpp @@ -206,32 +206,27 @@ void LLMotionController::purgeExcessMotions() } } - std::set<LLUUID> motions_to_kill; + std::vector<LLUUID> motions_to_kill; + motions_to_kill.reserve(100); if (mLoadedMotions.size() > MAX_MOTION_INSTANCES) { // too many motions active this frame, kill all blenders mPoseBlender.clearBlenders(); - for (motion_set_t::iterator loaded_motion_it = mLoadedMotions.begin(); - loaded_motion_it != mLoadedMotions.end(); - ++loaded_motion_it) + for (LLMotion* cur_motionp : mLoadedMotions) { - LLMotion* cur_motionp = *loaded_motion_it; // motion isn't playing, delete it if (!isMotionActive(cur_motionp)) { - motions_to_kill.insert(cur_motionp->getID()); + motions_to_kill.push_back(cur_motionp->getID()); } } } // clean up all inactive, loaded motions - for (std::set<LLUUID>::iterator motion_it = motions_to_kill.begin(); - motion_it != motions_to_kill.end(); - ++motion_it) + for (const LLUUID& motion_id : motions_to_kill) { // look up the motion again by ID to get canonical instance // and kill it only if that one is inactive - LLUUID motion_id = *motion_it; LLMotion* motionp = findMotion(motion_id); if (motionp && !isMotionActive(motionp)) { @@ -563,11 +558,8 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty memset(&last_joint_signature, 0, sizeof(U8) * LL_CHARACTER_MAX_ANIMATED_JOINTS); // iterate through active motions in chronological order - for (motion_list_t::iterator iter = mActiveMotions.begin(); - iter != mActiveMotions.end(); ) + for (LLMotion* motionp : mActiveMotions) { - motion_list_t::iterator curiter = iter++; - LLMotion* motionp = *curiter; if (motionp->getBlendType() != anim_type) { continue; @@ -1114,10 +1106,9 @@ void LLMotionController::flushAllMotions() mCharacter->removeAnimationData("Hand Pose"); // restart motions - for (std::vector<std::pair<LLUUID,F32> >::iterator iter = active_motions.begin(); - iter != active_motions.end(); ++iter) + for (const auto& motion_pair : active_motions) { - startMotion(iter->first, iter->second); + startMotion(motion_pair.first, motion_pair.second); } } diff --git a/indra/llcharacter/llmotioncontroller.h b/indra/llcharacter/llmotioncontroller.h index 637ee4d2bba..7b5c29699e8 100644 --- a/indra/llcharacter/llmotioncontroller.h +++ b/indra/llcharacter/llmotioncontroller.h @@ -40,6 +40,8 @@ #include "llstatemachine.h" #include "llstring.h" +#include <boost/unordered_map.hpp> + //----------------------------------------------------------------------------- // Class predeclaration // This is necessary because llcharacter.h includes this file. @@ -73,7 +75,7 @@ class LLMotionRegistry protected: - typedef std::map<LLUUID, LLMotionConstructor> motion_map_t; + typedef boost::unordered_map<LLUUID, LLMotionConstructor> motion_map_t; motion_map_t mMotionTable; }; @@ -208,7 +210,7 @@ class LLMotionController // Once an animations is loaded, it will be initialized and put on the mLoadedMotions list. // Any animation that is currently playing also sits in the mActiveMotions list. - typedef std::map<LLUUID, LLMotion*> motion_map_t; + typedef boost::unordered_map<LLUUID, LLMotion*> motion_map_t; motion_map_t mAllMotions; motion_set_t mLoadingMotions; diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 3b793aa23c9..9e8f94d4cf0 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -41,7 +41,7 @@ # include <unistd.h> #endif // !LL_WINDOWS #include <vector> -#include <unordered_map> +#include <boost/unordered_map.hpp> #include "string.h" #include "llapp.h" @@ -487,7 +487,7 @@ namespace LLError LevelMap mClassLevelMap; LevelMap mFileLevelMap; LevelMap mTagLevelMap; - std::unordered_map<std::string, unsigned int> mUniqueLogMessages; + boost::unordered_map<std::string, unsigned int> mUniqueLogMessages; LLError::FatalFunction mCrashFunction; LLError::TimeFunction mTimeFunction; diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 365ffc1184b..d46d54ee2b7 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -98,8 +98,8 @@ extern LLPipeline gPipeline; // Statics for object lookup tables. U32 LLViewerObjectList::sSimulatorMachineIndex = 1; // Not zero deliberately, to speed up index check. -std::unordered_map<U64, U32> LLViewerObjectList::sIPAndPortToIndex; -std::unordered_map<U64, LLUUID> LLViewerObjectList::sIndexAndLocalIDToUUID; +boost::unordered_map<U64, U32> LLViewerObjectList::sIPAndPortToIndex; +boost::unordered_map<U64, LLUUID> LLViewerObjectList::sIndexAndLocalIDToUUID; LLViewerObjectList::LLViewerObjectList() { diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index 5ac11271c49..9f775ef6ac1 100644 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -40,7 +40,7 @@ #include "llcoros.h" // system includes -#include <unordered_map> +#include <boost/unordered_map.hpp> class LLCamera; class LLNetMap; @@ -213,7 +213,7 @@ class LLViewerObjectList uuid_set_t mDeadObjects; - std::unordered_map<LLUUID, LLPointer<LLViewerObject> > mUUIDObjectMap; + boost::unordered_map<LLUUID, LLPointer<LLViewerObject> > mUUIDObjectMap; //set of objects that need to update their cost uuid_set_t mStaleObjectCost; @@ -228,9 +228,9 @@ class LLViewerObjectList S32 mCurLazyUpdateIndex; static U32 sSimulatorMachineIndex; - static std::unordered_map<U64, U32> sIPAndPortToIndex; + static boost::unordered_map<U64, U32> sIPAndPortToIndex; - static std::unordered_map<U64, LLUUID> sIndexAndLocalIDToUUID; + static boost::unordered_map<U64, LLUUID> sIndexAndLocalIDToUUID; std::set<LLViewerObject *> mSelectPickList; -- GitLab