Commits

davep  committed dfbd5a9

reapply 15b05dc53770: MAINT-646 Profile based optimization -- add a lookup map for joints to remove hotspot in LLJoint::findJoint

  • Participants
  • Parent commits a309d4b

Comments (0)

Files changed (2)

File indra/newview/llvoavatar.cpp

 	lldebugs << "LLVOAvatar Destructor (0x" << this << ") id:" << mID << llendl;
 
 	mRoot.removeAllChildren();
+	mJointMap.clear();
 
 	deleteAndClearArray(mSkeleton);
 	deleteAndClearArray(mCollisionVolumes);
 	// remove all of mRoot's children
 	//-------------------------------------------------------------------------
 	mRoot.removeAllChildren();
+	mJointMap.clear();
 	mIsBuilt = FALSE;
 
 	//-------------------------------------------------------------------------
 // RN: avatar joints are multi-rooted to include screen-based attachments
 LLJoint *LLVOAvatar::getJoint( const std::string &name )
 {
-	LLJoint* jointp = mRoot.findJoint(name);
+	joint_map_t::iterator iter = mJointMap.find(name);
+
+	LLJoint* jointp = NULL;
+
+	if (iter == mJointMap.end())
+	{ //search for joint and cache found joint in lookup table
+		LLJoint* jointp = mRoot.findJoint(name);
+		mJointMap[name] = jointp;
+	}
+	else
+	{ //return cached pointer
+		jointp = iter->second;
+	}
+
 	return jointp;
 }
 

File indra/newview/llvoavatar.h

 
 	LLVector3			mHeadOffset; // current head position
 	LLViewerJoint		mRoot;
+
+	typedef std::map<std::string, LLJoint*> joint_map_t;
+	joint_map_t			mJointMap;
+
 protected:
 	static BOOL			parseSkeletonFile(const std::string& filename);
 	void				buildCharacter();