From d0f115ae093e8268da2a3245d6cb2f3bcc544f1c Mon Sep 17 00:00:00 2001
From: Fawrsk <fawrsk@gmail.com>
Date: Thu, 5 Jan 2023 07:42:27 -0400
Subject: SL-18893 Cleanup for loops in llcharacter to use C++11 range based
 for loops (#42)

---
 indra/llcharacter/llanimationstates.cpp     |  7 ++-
 indra/llcharacter/llbvhloader.cpp           | 75 +++++++++++------------------
 indra/llcharacter/llcharacter.cpp           |  4 +-
 indra/llcharacter/llcharacter.h             | 13 ++---
 indra/llcharacter/llgesture.cpp             |  9 ++--
 indra/llcharacter/lljoint.cpp               | 56 ++++++++-------------
 indra/llcharacter/llkeyframemotion.cpp      | 37 +++++---------
 indra/llcharacter/llkeyframemotionparam.cpp | 58 +++++++++-------------
 indra/llcharacter/llmotioncontroller.cpp    | 27 ++++-------
 indra/llcharacter/llmultigesture.cpp        |  4 +-
 indra/llcharacter/llpose.cpp                |  6 +--
 indra/llcharacter/llstatemachine.cpp        | 58 +++++++++-------------
 12 files changed, 131 insertions(+), 223 deletions(-)

(limited to 'indra/llcharacter')

diff --git a/indra/llcharacter/llanimationstates.cpp b/indra/llcharacter/llanimationstates.cpp
index c16cae1bbc..c8709dda19 100644
--- a/indra/llcharacter/llanimationstates.cpp
+++ b/indra/llcharacter/llanimationstates.cpp
@@ -379,12 +379,11 @@ LLUUID LLAnimationLibrary::stringToAnimState( const std::string& name, BOOL allo
 
 	if (true_name)
 	{
-		for (anim_map_t::iterator iter = mAnimMap.begin();
-			 iter != mAnimMap.end(); iter++)
+		for (anim_map_t::value_type anim_pair : mAnimMap)
 		{
-			if (iter->second == true_name)
+			if (anim_pair.second == true_name)
 			{
-				id = iter->first;
+				id = anim_pair.first;
 				break;
 			}
 		}
diff --git a/indra/llcharacter/llbvhloader.cpp b/indra/llcharacter/llbvhloader.cpp
index c38614b0b4..70f6c0c4c9 100644
--- a/indra/llcharacter/llbvhloader.cpp
+++ b/indra/llcharacter/llbvhloader.cpp
@@ -156,10 +156,9 @@ LLBVHLoader::LLBVHLoader(const char* buffer, ELoadStatus &loadStatus, S32 &error
 	}
     
     // Recognize all names we've been told are legal.
-    std::map<std::string, std::string>::iterator iter;
-    for (iter = joint_alias_map.begin(); iter != joint_alias_map.end(); iter++)
+    for (std::map<std::string, std::string>::value_type alias_pair : joint_alias_map)
     {
-        makeTranslation( iter->first , iter->second );
+        makeTranslation( alias_pair.first , alias_pair.second );
     }
 	
 	char error_text[128];		/* Flawfinder: ignore */
@@ -951,9 +950,8 @@ ELoadStatus LLBVHLoader::loadBVHFile(const char *buffer, char* error_text, S32 &
 void LLBVHLoader::applyTranslations()
 {
 	JointVector::iterator ji;
-	for (ji = mJoints.begin(); ji != mJoints.end(); ++ji )
+	for (Joint* joint : mJoints)
 	{
-		Joint *joint = *ji;
 		//----------------------------------------------------------------
 		// Look for a translation for this joint.
 		// If none, skip to next joint
@@ -1067,9 +1065,8 @@ void LLBVHLoader::optimize()
 	}
 
 	JointVector::iterator ji;
-	for (ji = mJoints.begin(); ji != mJoints.end(); ++ji)
+	for (Joint* joint : mJoints)
 	{
-		Joint *joint = *ji;
 		BOOL pos_changed = FALSE;
 		BOOL rot_changed = FALSE;
 
@@ -1294,15 +1291,12 @@ U32 LLBVHLoader::getOutputSize()
 // writes contents to datapacker
 BOOL LLBVHLoader::serialize(LLDataPacker& dp)
 {
-	JointVector::iterator ji;
-	KeyVector::iterator ki;
 	F32 time;
 
 	// count number of non-ignored joints
 	S32 numJoints = 0;
-	for (ji=mJoints.begin(); ji!=mJoints.end(); ++ji)
+	for (Joint* joint : mJoints)
 	{
-		Joint *joint = *ji;
 		if ( ! joint->mIgnore )
 			numJoints++;
 	}
@@ -1321,11 +1315,8 @@ BOOL LLBVHLoader::serialize(LLDataPacker& dp)
 	dp.packU32(mHand, "hand_pose");
 	dp.packU32(numJoints, "num_joints");
 
-	for (	ji = mJoints.begin();
-			ji != mJoints.end();
-			++ji )
+	for (Joint* joint : mJoints)
 	{
-		Joint *joint = *ji;
 		// if ignored, skip it
 		if ( joint->mIgnore )
 			continue;
@@ -1348,17 +1339,15 @@ BOOL LLBVHLoader::serialize(LLDataPacker& dp)
 		Joint *mergeParent = NULL;
 		Joint *mergeChild = NULL;
 
-		JointVector::iterator mji;
-		for (mji=mJoints.begin(); mji!=mJoints.end(); ++mji)
+		for (Joint* mjoint : mJoints)
 		{
-			Joint *mjoint = *mji;
 			if ( !joint->mMergeParentName.empty() && (mjoint->mName == joint->mMergeParentName) )
 			{
-				mergeParent = *mji;
+				mergeParent = mjoint;
 			}
 			if ( !joint->mMergeChildName.empty() && (mjoint->mName == joint->mMergeChildName) )
 			{
-				mergeChild = *mji;
+				mergeChild = mjoint;
 			}
 		}
 
@@ -1367,19 +1356,17 @@ BOOL LLBVHLoader::serialize(LLDataPacker& dp)
 		LLQuaternion::Order order = bvhStringToOrder( joint->mOrder );
 		S32 outcount = 0;
 		S32 frame = 0;
-		for (	ki = joint->mKeys.begin();
-				ki != joint->mKeys.end();
-				++ki )
+		for (Key& key : joint->mKeys)
 		{
 
 			if ((frame == 0) && joint->mRelativeRotationKey)
 			{
-				first_frame_rot = mayaQ( ki->mRot[0], ki->mRot[1], ki->mRot[2], order);
+				first_frame_rot = mayaQ( key.mRot[0], key.mRot[1], key.mRot[2], order);
 				
 				fixup_rot.shortestArc(LLVector3::z_axis * first_frame_rot * frameRot, LLVector3::z_axis);
 			}
 
-			if (ki->mIgnoreRot)
+			if (key.mIgnoreRot)
 			{
 				frame++;
 				continue;
@@ -1418,7 +1405,7 @@ BOOL LLBVHLoader::serialize(LLDataPacker& dp)
 				mergeChildRot.loadIdentity();
 			}
 
-			LLQuaternion inRot = mayaQ( ki->mRot[0], ki->mRot[1], ki->mRot[2], order);
+			LLQuaternion inRot = mayaQ( key.mRot[0], key.mRot[1], key.mRot[2], order);
 
 			LLQuaternion outRot =  frameRotInv* mergeChildRot * inRot * mergeParentRot * ~first_frame_rot * frameRot * offsetRot;
 
@@ -1446,16 +1433,14 @@ BOOL LLBVHLoader::serialize(LLDataPacker& dp)
 			LLVector3 relKey;
 
 			frame = 0;
-			for (	ki = joint->mKeys.begin();
-					ki != joint->mKeys.end();
-					++ki )
+			for (Key& key : joint->mKeys)
 			{
 				if ((frame == 0) && joint->mRelativePositionKey)
 				{
-					relKey.setVec(ki->mPos);
+					relKey.setVec(key.mPos);
 				}
 
-				if (ki->mIgnorePos)
+				if (key.mIgnorePos)
 				{
 					frame++;
 					continue;
@@ -1463,7 +1448,7 @@ BOOL LLBVHLoader::serialize(LLDataPacker& dp)
 
 				time = llmax((F32)(frame - NUMBER_OF_IGNORED_FRAMES_AT_START), 0.0f) * mFrameTime; // Time elapsed before this frame starts.
 
-				LLVector3 inPos = (LLVector3(ki->mPos) - relKey) * ~first_frame_rot;// * fixup_rot;
+				LLVector3 inPos = (LLVector3(key.mPos) - relKey) * ~first_frame_rot;// * fixup_rot;
 				LLVector3 outPos = inPos * frameRot * offsetRot;
 
 				outPos *= INCHES_TO_METERS;
@@ -1496,24 +1481,22 @@ BOOL LLBVHLoader::serialize(LLDataPacker& dp)
 	S32 num_constraints = (S32)mConstraints.size();
 	dp.packS32(num_constraints, "num_constraints");
 
-	for (ConstraintVector::iterator constraint_it = mConstraints.begin();
-		constraint_it != mConstraints.end();
-		constraint_it++)
+	for (Constraint& constraint : mConstraints)
 		{
-			U8 byte = constraint_it->mChainLength;
+			U8 byte = constraint.mChainLength;
 			dp.packU8(byte, "chain_length");
 			
-			byte = constraint_it->mConstraintType;
+			byte = constraint.mConstraintType;
 			dp.packU8(byte, "constraint_type");
-			dp.packBinaryDataFixed((U8*)constraint_it->mSourceJointName, 16, "source_volume");
-			dp.packVector3(constraint_it->mSourceOffset, "source_offset");
-			dp.packBinaryDataFixed((U8*)constraint_it->mTargetJointName, 16, "target_volume");
-			dp.packVector3(constraint_it->mTargetOffset, "target_offset");
-			dp.packVector3(constraint_it->mTargetDir, "target_dir");
-			dp.packF32(constraint_it->mEaseInStart,	"ease_in_start");
-			dp.packF32(constraint_it->mEaseInStop,	"ease_in_stop");
-			dp.packF32(constraint_it->mEaseOutStart,	"ease_out_start");
-			dp.packF32(constraint_it->mEaseOutStop,	"ease_out_stop");
+			dp.packBinaryDataFixed((U8*)constraint.mSourceJointName, 16, "source_volume");
+			dp.packVector3(constraint.mSourceOffset, "source_offset");
+			dp.packBinaryDataFixed((U8*)constraint.mTargetJointName, 16, "target_volume");
+			dp.packVector3(constraint.mTargetOffset, "target_offset");
+			dp.packVector3(constraint.mTargetDir, "target_dir");
+			dp.packF32(constraint.mEaseInStart,	"ease_in_start");
+			dp.packF32(constraint.mEaseInStop,	"ease_in_stop");
+			dp.packF32(constraint.mEaseOutStart,	"ease_out_start");
+			dp.packF32(constraint.mEaseOutStop,	"ease_out_stop");
 		}
 
 	
diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp
index 376f096642..cf6be8daf0 100644
--- a/indra/llcharacter/llcharacter.cpp
+++ b/indra/llcharacter/llcharacter.cpp
@@ -246,10 +246,8 @@ void LLCharacter::dumpCharacter( LLJoint* joint )
 	LL_INFOS() << "DEBUG: " << joint->getName() << " (" << (joint->getParent()?joint->getParent()->getName():std::string("ROOT")) << ")" << LL_ENDL;
 
 	// recurse
-	for (LLJoint::joints_t::iterator iter = joint->mChildren.begin();
-		 iter != joint->mChildren.end(); ++iter)
+	for (LLJoint* child_joint : joint->mChildren)
 	{
-		LLJoint* child_joint = *iter;
 		dumpCharacter(child_joint);
 	}
 }
diff --git a/indra/llcharacter/llcharacter.h b/indra/llcharacter/llcharacter.h
index 2fac5f53a6..bc0c2ec0d3 100644
--- a/indra/llcharacter/llcharacter.h
+++ b/indra/llcharacter/llcharacter.h
@@ -218,11 +218,9 @@ public:
 	S32 getVisualParamCountInGroup(const EVisualParamGroup group) const
 	{
 		S32 rtn = 0;
-		for (visual_param_index_map_t::const_iterator iter = mVisualParamIndexMap.begin();
-		     iter != mVisualParamIndexMap.end();
-		     /**/ )
+		for (visual_param_index_map_t::value_type index_pair : mVisualParamIndexMap)
 		{
-			if ((iter++)->second->getGroup() == group)
+			if (index_pair.second->getGroup() == group)
 			{
 				++rtn;
 			}
@@ -237,11 +235,10 @@ public:
 	}
 	S32 getVisualParamID(LLVisualParam *id)
 	{
-		visual_param_index_map_t::iterator iter;
-		for (iter = mVisualParamIndexMap.begin(); iter != mVisualParamIndexMap.end(); iter++)
+		for (visual_param_index_map_t::value_type index_pair : mVisualParamIndexMap)
 		{
-			if (iter->second == id)
-				return iter->first;
+			if (index_pair.second == id)
+				return index_pair.first;
 		}
 		return 0;
 	}
diff --git a/indra/llcharacter/llgesture.cpp b/indra/llcharacter/llgesture.cpp
index 37904936d8..e9a4475707 100644
--- a/indra/llcharacter/llgesture.cpp
+++ b/indra/llcharacter/llgesture.cpp
@@ -199,15 +199,14 @@ BOOL LLGestureList::triggerAndReviseString(const std::string &string, std::strin
 	typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
 	boost::char_separator<char> sep(" ");
 	tokenizer tokens(string, sep);
-	tokenizer::iterator token_iter;
 
-	for( token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter)
+	for(std::string cur_token : tokens)
 	{
 		LLGesture* gesture = NULL;
 
 		if( !found_gestures ) // Only pay attention to the first gesture in the string.
 		{
-			std::string cur_token_lower = *token_iter;
+			std::string cur_token_lower = cur_token;
 			LLStringUtil::toLower(cur_token_lower);
 
 			for (U32 i = 0; i < mList.size(); i++)
@@ -228,7 +227,7 @@ BOOL LLGestureList::triggerAndReviseString(const std::string &string, std::strin
 						LLStringUtil::toLower(output_lower);
 						if( cur_token_lower == output_lower )
 						{
-							revised_string->append(*token_iter);
+							revised_string->append(cur_token);
 						}
 						else
 						{
@@ -249,7 +248,7 @@ BOOL LLGestureList::triggerAndReviseString(const std::string &string, std::strin
 			{
 				revised_string->append( " " );
 			}
-			revised_string->append( *token_iter );
+			revised_string->append( cur_token );
 		}
 
 		first_token = FALSE;
diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp
index d72282ab42..282db5c88b 100644
--- a/indra/llcharacter/lljoint.cpp
+++ b/indra/llcharacter/lljoint.cpp
@@ -67,11 +67,10 @@ void LLVector3OverrideMap::showJointVector3Overrides( std::ostringstream& os ) c
 	map_type::const_iterator max_it = std::max_element(m_map.begin(),
 													   m_map.end(),
 													   attachment_map_iter_compare_key<map_type::value_type>);
-	for (map_type::const_iterator it = m_map.begin();
-		 it != m_map.end(); ++it)
+	for (const map_type::value_type pos_pair : m_map)
 	{
-		const LLVector3& pos = it->second;
-		os << " " << "[" << it->first <<": " << pos << "]" << ((it==max_it) ? "*" : "");
+		const LLVector3& pos = pos_pair.second;
+		os << " " << "[" << pos_pair.first <<": " << pos << "]" << ((pos_pair==(*max_it)) ? "*" : "");
 	}
 }
 
@@ -209,10 +208,8 @@ void LLJoint::touch(U32 flags)
 			child_flags |= POSITION_DIRTY;
 		}
 
-		for (joints_t::iterator iter = mChildren.begin();
-			 iter != mChildren.end(); ++iter)
+		for (LLJoint* joint : mChildren)
 		{
-			LLJoint* joint = *iter;
 			joint->touch(child_flags);
 		}
 	}
@@ -251,10 +248,8 @@ LLJoint *LLJoint::findJoint( const std::string &name )
 	if (name == getName())
 		return this;
 
-	for (joints_t::iterator iter = mChildren.begin();
-		 iter != mChildren.end(); ++iter)
+	for (LLJoint* joint : mChildren)
 	{
-		LLJoint* joint = *iter;
 		LLJoint *found = joint->findJoint(name);
 		if (found)
 		{
@@ -514,10 +509,9 @@ void LLJoint::getAllAttachmentPosOverrides(S32& num_pos_overrides,
                                            std::set<LLVector3>& distinct_pos_overrides) const
 {
     num_pos_overrides = m_attachmentPosOverrides.count();
-    LLVector3OverrideMap::map_type::const_iterator it = m_attachmentPosOverrides.getMap().begin();
-    for (; it != m_attachmentPosOverrides.getMap().end(); ++it)
+    for (LLVector3OverrideMap::map_type::value_type pos_override_pair : m_attachmentPosOverrides.getMap())
     {
-        distinct_pos_overrides.insert(it->second);
+        distinct_pos_overrides.insert(pos_override_pair.second);
     }
 }
                                         
@@ -528,10 +522,9 @@ void LLJoint::getAllAttachmentScaleOverrides(S32& num_scale_overrides,
                                              std::set<LLVector3>& distinct_scale_overrides) const
 {
     num_scale_overrides = m_attachmentScaleOverrides.count();
-    LLVector3OverrideMap::map_type::const_iterator it = m_attachmentScaleOverrides.getMap().begin();
-    for (; it != m_attachmentScaleOverrides.getMap().end(); ++it)
+    for (LLVector3OverrideMap::map_type::value_type scale_override_pair : m_attachmentScaleOverrides.getMap())
     {
-        distinct_scale_overrides.insert(it->second);
+        distinct_scale_overrides.insert(scale_override_pair.second);
     }
 }
                                         
@@ -556,10 +549,9 @@ void LLJoint::showAttachmentPosOverrides(const std::string& av_info) const
     {
         LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " has " << count << " attachment pos overrides" << LL_ENDL;
 		std::set<LLVector3> distinct_offsets;
-        LLVector3OverrideMap::map_type::const_iterator it = m_attachmentPosOverrides.getMap().begin();
-        for (; it != m_attachmentPosOverrides.getMap().end(); ++it)
+        for (LLVector3OverrideMap::map_type::value_type pos_override_pair : m_attachmentPosOverrides.getMap())
         {
-            distinct_offsets.insert(it->second);
+            distinct_offsets.insert(pos_override_pair.second);
         }
         if (distinct_offsets.size()>1)
         {
@@ -569,11 +561,10 @@ void LLJoint::showAttachmentPosOverrides(const std::string& av_info) const
         {
             LL_DEBUGS("Avatar") << "no conflicts" << LL_ENDL;
         }
-        std::set<LLVector3>::iterator dit = distinct_offsets.begin();
-        for ( ; dit != distinct_offsets.end(); ++dit)
+        for (const LLVector3& offset : distinct_offsets)
         {
-            std::string highlight = (has_active_override && *dit == active_override) ? "*" : "";
-            LL_DEBUGS("Avatar") << "  POS " << highlight << "" << (*dit) << " default " << mDefaultPosition << LL_ENDL;
+            std::string highlight = (has_active_override && offset == active_override) ? "*" : "";
+            LL_DEBUGS("Avatar") << "  POS " << highlight << "" << offset << " default " << mDefaultPosition << LL_ENDL;
         }
 	}
 }
@@ -717,10 +708,9 @@ void LLJoint::showAttachmentScaleOverrides(const std::string& av_info) const
     {
         LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " has " << count << " attachment scale overrides" << LL_ENDL;
 		std::set<LLVector3> distinct_offsets;
-        LLVector3OverrideMap::map_type::const_iterator it = m_attachmentScaleOverrides.getMap().begin();
-        for (; it != m_attachmentScaleOverrides.getMap().end(); ++it)
+        for (LLVector3OverrideMap::map_type::value_type scale_override_pair : m_attachmentScaleOverrides.getMap())
         {
-            distinct_offsets.insert(it->second);
+            distinct_offsets.insert(scale_override_pair.second);
         }
         if (distinct_offsets.size()>1)
         {
@@ -731,10 +721,10 @@ void LLJoint::showAttachmentScaleOverrides(const std::string& av_info) const
             LL_DEBUGS("Avatar") << "no conflicts" << LL_ENDL;
         }
         std::set<LLVector3>::iterator dit = distinct_offsets.begin();
-        for ( ; dit != distinct_offsets.end(); ++dit)
+        for (const LLVector3& offset : distinct_offsets)
         {
-            std::string highlight = (has_active_override && *dit == active_override) ? "*" : "";
-            LL_DEBUGS("Avatar") << "  POS " << highlight << "" << (*dit) << " default " << mDefaultScale << LL_ENDL;
+            std::string highlight = (has_active_override && offset == active_override) ? "*" : "";
+            LL_DEBUGS("Avatar") << "  POS " << highlight << "" << offset << " default " << mDefaultScale << LL_ENDL;
         }
 	}
 }
@@ -993,10 +983,8 @@ void LLJoint::updateWorldMatrixChildren()
 	{
 		updateWorldMatrix();
 	}
-	for (joints_t::iterator iter = mChildren.begin();
-		 iter != mChildren.end(); ++iter)
+	for (LLJoint* joint : mChildren)
 	{
-		LLJoint* joint = *iter;
 		joint->updateWorldMatrixChildren();
 	}
 }
@@ -1040,10 +1028,8 @@ void LLJoint::clampRotation(LLQuaternion old_rot, LLQuaternion new_rot)
 {
 	LLVector3 main_axis(1.f, 0.f, 0.f);
 
-	for (joints_t::iterator iter = mChildren.begin();
-		 iter != mChildren.end(); ++iter)
+	for (LLJoint* joint : mChildren)
 	{
-		LLJoint* joint = *iter;
 		if (joint->isAnimatable())
 		{
 			main_axis = joint->getPosition();
diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp
index ebf7454a61..04c1475161 100644
--- a/indra/llcharacter/llkeyframemotion.cpp
+++ b/indra/llcharacter/llkeyframemotion.cpp
@@ -626,10 +626,8 @@ BOOL LLKeyframeMotion::setupPose()
 	}
 
 	// initialize joint constraints
-	for (JointMotionList::constraint_list_t::iterator iter = mJointMotionList->mConstraints.begin();
-		 iter != mJointMotionList->mConstraints.end(); ++iter)
+	for (JointConstraintSharedData* shared_constraintp : mJointMotionList->mConstraints)
 	{
-		JointConstraintSharedData* shared_constraintp = *iter;
 		JointConstraint* constraintp = new JointConstraint(shared_constraintp);
 		initializeConstraint(constraintp);
 		mConstraints.push_front(constraintp);
@@ -764,19 +762,15 @@ void LLKeyframeMotion::applyConstraints(F32 time, U8* joint_mask)
 	if (mCharacter->getSkeletonSerialNum() != mLastSkeletonSerialNum)
 	{
 		mLastSkeletonSerialNum = mCharacter->getSkeletonSerialNum();
-		for (constraint_list_t::iterator iter = mConstraints.begin();
-			 iter != mConstraints.end(); ++iter)
+		for (JointConstraint* constraintp : mConstraints)
 		{
-			JointConstraint* constraintp = *iter;
 			initializeConstraint(constraintp);
 		}
 	}
 
 	// apply constraints
-	for (constraint_list_t::iterator iter = mConstraints.begin();
-		 iter != mConstraints.end(); ++iter)
+	for (JointConstraint* constraintp : mConstraints)
 	{
-		JointConstraint* constraintp = *iter;
 		applyConstraint(constraintp, time, joint_mask);
 	}
 }
@@ -786,10 +780,8 @@ void LLKeyframeMotion::applyConstraints(F32 time, U8* joint_mask)
 //-----------------------------------------------------------------------------
 void LLKeyframeMotion::onDeactivate()
 {
-	for (constraint_list_t::iterator iter = mConstraints.begin();
-		 iter != mConstraints.end(); ++iter)
+	for (JointConstraint* constraintp : mConstraints)
 	{
-		JointConstraint* constraintp = *iter;
 		deactivateConstraint(constraintp);
 	}
 }
@@ -2007,10 +1999,9 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
 		success &= dp.packS32(joint_motionp->mRotationCurve.mNumKeys, "num_rot_keys");
 
 		LL_DEBUGS("BVH") << "Joint " << joint_motionp->mJointName << LL_ENDL;
-		for (RotationCurve::key_map_t::iterator iter = joint_motionp->mRotationCurve.mKeys.begin();
-			 iter != joint_motionp->mRotationCurve.mKeys.end(); ++iter)
+		for (RotationCurve::key_map_t::value_type rot_pair : joint_motionp->mRotationCurve.mKeys)
 		{
-			RotationKey& rot_key = iter->second;
+			RotationKey& rot_key = rot_pair.second;
 			U16 time_short = F32_to_U16(rot_key.mTime, 0.f, mJointMotionList->mDuration);
 			success &= dp.packU16(time_short, "time");
 
@@ -2029,10 +2020,9 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
 		}
 
 		success &= dp.packS32(joint_motionp->mPositionCurve.mNumKeys, "num_pos_keys");
-		for (PositionCurve::key_map_t::iterator iter = joint_motionp->mPositionCurve.mKeys.begin();
-			 iter != joint_motionp->mPositionCurve.mKeys.end(); ++iter)
+		for (PositionCurve::key_map_t::value_type pos_pair : joint_motionp->mPositionCurve.mKeys)
 		{
-			PositionKey& pos_key = iter->second;
+			PositionKey& pos_key = pos_pair.second;
 			U16 time_short = F32_to_U16(pos_key.mTime, 0.f, mJointMotionList->mDuration);
 			success &= dp.packU16(time_short, "time");
 
@@ -2051,10 +2041,8 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
 
 	success &= dp.packS32(mJointMotionList->mConstraints.size(), "num_constraints");
     LL_DEBUGS("BVH") << "num_constraints " << mJointMotionList->mConstraints.size() << LL_ENDL;
-	for (JointMotionList::constraint_list_t::const_iterator iter = mJointMotionList->mConstraints.begin();
-		 iter != mJointMotionList->mConstraints.end(); ++iter)
+	for (JointConstraintSharedData* shared_constraintp : mJointMotionList->mConstraints)
 	{
-		JointConstraintSharedData* shared_constraintp = *iter;
 		success &= dp.packU8(shared_constraintp->mChainLength, "chain_length");
 		success &= dp.packU8(shared_constraintp->mConstraintType, "constraint_type");
 		char source_volume[16]; /* Flawfinder: ignore */
@@ -2406,14 +2394,13 @@ void LLKeyframeDataCache::dumpDiagInfo()
 	LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
 
 	// print each loaded mesh, and it's memory usage
-	for (keyframe_data_map_t::iterator map_it = sKeyframeDataMap.begin();
-		 map_it != sKeyframeDataMap.end(); ++map_it)
+	for (keyframe_data_map_t::value_type data_pair : sKeyframeDataMap)
 	{
 		U32 joint_motion_kb;
 
-		LLKeyframeMotion::JointMotionList *motion_list_p = map_it->second;
+		LLKeyframeMotion::JointMotionList *motion_list_p = data_pair.second;
 
-		LL_INFOS() << "Motion: " << map_it->first << LL_ENDL;
+		LL_INFOS() << "Motion: " << data_pair.first << LL_ENDL;
 
 		joint_motion_kb = motion_list_p->dumpDiagInfo();
 
diff --git a/indra/llcharacter/llkeyframemotionparam.cpp b/indra/llcharacter/llkeyframemotionparam.cpp
index aba1c5db39..fce445fee7 100644
--- a/indra/llcharacter/llkeyframemotionparam.cpp
+++ b/indra/llcharacter/llkeyframemotionparam.cpp
@@ -64,13 +64,11 @@ LLKeyframeMotionParam::LLKeyframeMotionParam( const LLUUID &id) : LLMotion(id)
 //-----------------------------------------------------------------------------
 LLKeyframeMotionParam::~LLKeyframeMotionParam()
 {
-	for (motion_map_t::iterator iter = mParameterizedMotions.begin();
-		 iter != mParameterizedMotions.end(); ++iter)
+	for (motion_map_t::value_type motion_pair : mParameterizedMotions)
 	{
-		motion_list_t& motionList = iter->second;
-		for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2)
+		motion_list_t& motionList = motion_pair.second;
+		for (const ParameterizedMotion& paramMotion : motionList)
 		{
-			const ParameterizedMotion& paramMotion = *iter2;
 			delete paramMotion.mMotion;
 		}
 		motionList.clear();
@@ -90,13 +88,11 @@ LLMotion::LLMotionInitStatus LLKeyframeMotionParam::onInitialize(LLCharacter *ch
 		return STATUS_FAILURE;	
 	}
 	
-	for (motion_map_t::iterator iter = mParameterizedMotions.begin();
-		 iter != mParameterizedMotions.end(); ++iter)
+	for (motion_map_t::value_type motion_pair : mParameterizedMotions)
 	{
-		motion_list_t& motionList = iter->second;
-		for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2)
+		motion_list_t& motionList = motion_pair.second;
+		for (const ParameterizedMotion& paramMotion : motionList)
 		{
-			const ParameterizedMotion& paramMotion = *iter2;
 			LLMotion* motion = paramMotion.mMotion;
 			motion->onInitialize(character);
 
@@ -139,13 +135,11 @@ LLMotion::LLMotionInitStatus LLKeyframeMotionParam::onInitialize(LLCharacter *ch
 //-----------------------------------------------------------------------------
 BOOL LLKeyframeMotionParam::onActivate()
 {
-	for (motion_map_t::iterator iter = mParameterizedMotions.begin();
-		 iter != mParameterizedMotions.end(); ++iter)
+	for (motion_map_t::value_type motion_pair : mParameterizedMotions)
 	{
-		motion_list_t& motionList = iter->second;
-		for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2)
+		motion_list_t& motionList = motion_pair.second;
+		for (const ParameterizedMotion& paramMotion : motionList)
 		{
-			const ParameterizedMotion& paramMotion = *iter2;
 			paramMotion.mMotion->activate(mActivationTimestamp);
 		}
 	}
@@ -162,23 +156,20 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask)
 	F32 weightFactor = 1.f / (F32)mParameterizedMotions.size();
 
 	// zero out all pose weights
-	for (motion_map_t::iterator iter = mParameterizedMotions.begin();
-		 iter != mParameterizedMotions.end(); ++iter)
+	for (motion_map_t::value_type motion_pair : mParameterizedMotions)
 	{
-		motion_list_t& motionList = iter->second;
-		for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2)
+		motion_list_t& motionList = motion_pair.second;
+		for (const ParameterizedMotion& paramMotion : motionList)
 		{
-			const ParameterizedMotion& paramMotion = *iter2;
 //			LL_INFOS() << "Weight for pose " << paramMotion.mMotion->getName() << " is " << paramMotion.mMotion->getPose()->getWeight() << LL_ENDL;
 			paramMotion.mMotion->getPose()->setWeight(0.f);
 		}
 	}
 
 
-	for (motion_map_t::iterator iter = mParameterizedMotions.begin();
-		 iter != mParameterizedMotions.end(); ++iter)
+	for (motion_map_t::value_type motion_pair : mParameterizedMotions)
 	{
-		const std::string& paramName = iter->first;
+		const std::string& paramName = motion_pair.first;
 		F32* paramValue = (F32 *)mCharacter->getAnimationData(paramName);
 		if (NULL == paramValue) // unexpected, but...
 		{
@@ -190,10 +181,9 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask)
 		const ParameterizedMotion* firstMotion = NULL;
 		const ParameterizedMotion* secondMotion = NULL;
 
-		motion_list_t& motionList = iter->second;
-		for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2)
+		motion_list_t& motionList = motion_pair.second;
+		for (const ParameterizedMotion& paramMotion : motionList)
 		{
-			const ParameterizedMotion& paramMotion = *iter2;
 			paramMotion.mMotion->onUpdate(time, joint_mask);
 			
 			F32 distToParam = paramMotion.mParam - *paramValue;
@@ -280,13 +270,11 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask)
 //-----------------------------------------------------------------------------
 void LLKeyframeMotionParam::onDeactivate()
 {
-	for (motion_map_t::iterator iter = mParameterizedMotions.begin();
-		 iter != mParameterizedMotions.end(); ++iter)
+	for (motion_map_t::value_type motion_pair : mParameterizedMotions)
 	{
-		motion_list_t& motionList = iter->second;
-		for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2)
+		motion_list_t& motionList = motion_pair.second;
+		for (const ParameterizedMotion& paramMotion : motionList)
 		{
-			const ParameterizedMotion& paramMotion = *iter2;
 			paramMotion.mMotion->onDeactivate();
 		}
 	}
@@ -318,13 +306,11 @@ BOOL LLKeyframeMotionParam::addKeyframeMotion(char *name, const LLUUID &id, char
 //-----------------------------------------------------------------------------
 void LLKeyframeMotionParam::setDefaultKeyframeMotion(char *name)
 {
-	for (motion_map_t::iterator iter = mParameterizedMotions.begin();
-		 iter != mParameterizedMotions.end(); ++iter)
+	for (motion_map_t::value_type motion_pair : mParameterizedMotions)
 	{
-		motion_list_t& motionList = iter->second;
-		for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2)
+		motion_list_t& motionList = motion_pair.second;
+		for (const ParameterizedMotion& paramMotion : motionList)
 		{
-			const ParameterizedMotion& paramMotion = *iter2;
 			if (paramMotion.mMotion->getName() == name)
 			{
 				mDefaultKeyframeMotion = paramMotion.mMotion;
diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp
index e66714388a..8716fbff56 100644
--- a/indra/llcharacter/llmotioncontroller.cpp
+++ b/indra/llcharacter/llmotioncontroller.cpp
@@ -211,11 +211,8 @@ void LLMotionController::purgeExcessMotions()
 	{
 		// 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))
 			{
@@ -225,13 +222,10 @@ void LLMotionController::purgeExcessMotions()
 	}
 	
 	// 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 (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))
 		{
@@ -1059,12 +1053,11 @@ LLMotion* LLMotionController::findMotion(const LLUUID& id) const
 void LLMotionController::dumpMotions()
 {
 	LL_INFOS() << "=====================================" << LL_ENDL;
-	for (motion_map_t::iterator iter = mAllMotions.begin();
-		 iter != mAllMotions.end(); iter++)
+	for (motion_map_t::value_type motion_pair : mAllMotions)
 	{
-		LLUUID id = iter->first;
+		LLUUID id = motion_pair.first;
 		std::string state_string;
-		LLMotion *motion = iter->second;
+		LLMotion *motion = motion_pair.second;
 		if (mLoadingMotions.find(motion) != mLoadingMotions.end())
 			state_string += std::string("l");
 		if (mLoadedMotions.find(motion) != mLoadedMotions.end())
@@ -1083,10 +1076,9 @@ void LLMotionController::dumpMotions()
 //-----------------------------------------------------------------------------
 void LLMotionController::deactivateAllMotions()
 {
-	for (motion_map_t::iterator iter = mAllMotions.begin();
-		 iter != mAllMotions.end(); iter++)
+	for (motion_map_t::value_type motion_pair : mAllMotions)
 	{
-		LLMotion* motionp = iter->second;
+		LLMotion* motionp = motion_pair.second;
 		deactivateMotionInstance(motionp);
 	}
 }
@@ -1118,10 +1110,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 (std::vector<std::pair<LLUUID,F32> >::value_type motion_pair : active_motions)
 	{
-		startMotion(iter->first, iter->second);
+		startMotion(motion_pair.first, motion_pair.second);
 	}
 }
 
diff --git a/indra/llcharacter/llmultigesture.cpp b/indra/llcharacter/llmultigesture.cpp
index 2045739c7f..7ed242f90a 100644
--- a/indra/llcharacter/llmultigesture.cpp
+++ b/indra/llcharacter/llmultigesture.cpp
@@ -88,10 +88,8 @@ S32 LLMultiGesture::getMaxSerialSize() const
 
 	max_size += 64;		// step count S32
 
-	std::vector<LLGestureStep*>::const_iterator it;
-	for (it = mSteps.begin(); it != mSteps.end(); ++it)
+	for (LLGestureStep* step : mSteps)
 	{
-		LLGestureStep* step = *it;
 		max_size += 64;	// type S32
 		max_size += step->getMaxSerialSize();
 	}
diff --git a/indra/llcharacter/llpose.cpp b/indra/llcharacter/llpose.cpp
index fc95fafd61..a7156a250b 100644
--- a/indra/llcharacter/llpose.cpp
+++ b/indra/llcharacter/llpose.cpp
@@ -148,11 +148,9 @@ LLJointState* LLPose::findJointState(const std::string &name)
 void LLPose::setWeight(F32 weight)
 {
 	joint_map_iterator iter;
-	for(iter = mJointMap.begin(); 
-		iter != mJointMap.end();
-		++iter)
+	for (joint_map_value_type joint_pair : mJointMap)
 	{
-		iter->second->setWeight(weight);
+		joint_pair.second->setWeight(weight);
 	}
 	mWeight = weight;
 }
diff --git a/indra/llcharacter/llstatemachine.cpp b/indra/llcharacter/llstatemachine.cpp
index b917db3117..320381e91e 100644
--- a/indra/llcharacter/llstatemachine.cpp
+++ b/indra/llcharacter/llstatemachine.cpp
@@ -169,10 +169,9 @@ void LLStateDiagram::setDefaultState(LLFSMState& default_state)
 S32 LLStateDiagram::numDeadendStates()
 {
 	S32 numDeadends = 0;
-	StateMap::iterator state_it;
-	for(state_it = mStates.begin(); state_it != mStates.end(); ++state_it)
+	for (StateMap::value_type state_pair : mStates)
 	{
-		if (state_it->second.size() == 0)
+		if (state_pair.second.size() == 0)
 		{
 			numDeadends++;
 		}
@@ -191,12 +190,11 @@ BOOL LLStateDiagram::stateIsValid(LLFSMState& state)
 
 LLFSMState* LLStateDiagram::getState(U32 state_id)
 {
-	StateMap::iterator state_it;
-	for(state_it = mStates.begin(); state_it != mStates.end(); ++state_it)
+	for (StateMap::value_type state_pair : mStates)
 	{
-		if (state_it->first->getID() == state_id)
+		if (state_pair.first->getID() == state_id)
 		{
-			return state_it->first;
+			return state_pair.first;
 		}
 	}
 	return NULL;
@@ -215,18 +213,16 @@ BOOL LLStateDiagram::saveDotFile(const std::string& filename)
 	}
 	apr_file_printf(dot_file, "digraph StateMachine {\n\tsize=\"100,100\";\n\tfontsize=40;\n\tlabel=\"Finite State Machine\";\n\torientation=landscape\n\tratio=.77\n");
 	
-	StateMap::iterator state_it;
-	for(state_it = mStates.begin(); state_it != mStates.end(); ++state_it)
+	for (StateMap::value_type state_pair : mStates)
 	{
-		apr_file_printf(dot_file, "\t\"%s\" [fontsize=28,shape=box]\n", state_it->first->getName().c_str());
+		apr_file_printf(dot_file, "\t\"%s\" [fontsize=28,shape=box]\n", state_pair.first->getName().c_str());
 	}
 	apr_file_printf(dot_file, "\t\"All States\" [fontsize=30,style=bold,shape=box]\n");
 
-	Transitions::iterator transitions_it;
-	for(transitions_it = mDefaultTransitions.begin(); transitions_it != mDefaultTransitions.end(); ++transitions_it)
+	for (Transitions::value_type transition_pair : mDefaultTransitions)
 	{
-		apr_file_printf(dot_file, "\t\"All States\" -> \"%s\" [label = \"%s\",fontsize=24];\n", transitions_it->second->getName().c_str(), 
-			transitions_it->second->getName().c_str());
+		apr_file_printf(dot_file, "\t\"All States\" -> \"%s\" [label = \"%s\",fontsize=24];\n", transition_pair.second->getName().c_str(),
+			transition_pair.second->getName().c_str());
 	}
 
 	if (mDefaultState)
@@ -235,18 +231,15 @@ BOOL LLStateDiagram::saveDotFile(const std::string& filename)
 	}
 
 	
-	for(state_it = mStates.begin(); state_it != mStates.end(); ++state_it)
+	for (StateMap::value_type state_pair : mStates)
 	{
-		LLFSMState *state = state_it->first;
+		LLFSMState *state = state_pair.first;
 
-		Transitions::iterator transitions_it;
-		for(transitions_it = state_it->second.begin();
-			transitions_it != state_it->second.end();
-			++transitions_it)
+		for (Transitions::value_type transition_pair : state_pair.second)
 		{
 			std::string state_name = state->getName();
-			std::string target_name = transitions_it->second->getName();
-			std::string transition_name = transitions_it->first->getName();
+			std::string target_name = transition_pair.second->getName();
+			std::string transition_name = transition_pair.first->getName();
 			apr_file_printf(dot_file, "\t\"%s\" -> \"%s\" [label = \"%s\",fontsize=24];\n", state->getName().c_str(), 
 				target_name.c_str(), 
 				transition_name.c_str());
@@ -265,25 +258,18 @@ std::ostream& operator<<(std::ostream &s, LLStateDiagram &FSM)
 		s << "Default State: " << FSM.mDefaultState->getName() << "\n";
 	}
 
-	LLStateDiagram::Transitions::iterator transitions_it;
-	for(transitions_it = FSM.mDefaultTransitions.begin(); 
-		transitions_it != FSM.mDefaultTransitions.end(); 
-		++transitions_it)
+	for (LLStateDiagram::Transitions::value_type transition_pair : FSM.mDefaultTransitions)
 	{
-		s << "Any State -- " << transitions_it->first->getName()
-			<< " --> " << transitions_it->second->getName() << "\n";
+		s << "Any State -- " << transition_pair.first->getName()
+			<< " --> " << transition_pair.second->getName() << "\n";
 	}
 
-	LLStateDiagram::StateMap::iterator state_it;
-	for(state_it = FSM.mStates.begin(); state_it != FSM.mStates.end(); ++state_it)
+	for (LLStateDiagram::StateMap::value_type state_pair : FSM.mStates)
 	{
-		LLStateDiagram::Transitions::iterator transitions_it;
-		for(transitions_it = state_it->second.begin();
-			transitions_it != state_it->second.end();
-			++transitions_it)
+		for (LLStateDiagram::Transitions::value_type transition_pair : state_pair.second)
 		{
-			s << state_it->first->getName() << " -- " << transitions_it->first->getName() 
-				<< " --> " << transitions_it->second->getName() << "\n";
+			s << state_pair.first->getName() << " -- " << transition_pair.first->getName()
+				<< " --> " << transition_pair.second->getName() << "\n";
 		}
 		s << "\n";
 	}
-- 
cgit v1.2.3


From 7419037ef6e8a5497283278baa8582b264d3aefa Mon Sep 17 00:00:00 2001
From: Fawrsk <fawrsk@gmail.com>
Date: Tue, 10 Jan 2023 05:43:27 -0400
Subject: SL-18893 Fixes for pull requests #38, #41, and #42 (#46)

Eliminate unnecessary copies, and remove uses of auto
---
 indra/llcharacter/llanimationstates.cpp     |  2 +-
 indra/llcharacter/llbvhloader.cpp           |  2 +-
 indra/llcharacter/llcharacter.h             |  4 ++--
 indra/llcharacter/llgesture.cpp             |  2 +-
 indra/llcharacter/lljoint.cpp               | 10 +++++-----
 indra/llcharacter/llkeyframemotion.cpp      |  6 +++---
 indra/llcharacter/llkeyframemotionparam.cpp | 14 +++++++-------
 indra/llcharacter/llmotioncontroller.cpp    |  6 +++---
 indra/llcharacter/llpose.cpp                |  2 +-
 indra/llcharacter/llstatemachine.cpp        | 18 +++++++++---------
 10 files changed, 33 insertions(+), 33 deletions(-)

(limited to 'indra/llcharacter')

diff --git a/indra/llcharacter/llanimationstates.cpp b/indra/llcharacter/llanimationstates.cpp
index c8709dda19..2e78e30405 100644
--- a/indra/llcharacter/llanimationstates.cpp
+++ b/indra/llcharacter/llanimationstates.cpp
@@ -379,7 +379,7 @@ LLUUID LLAnimationLibrary::stringToAnimState( const std::string& name, BOOL allo
 
 	if (true_name)
 	{
-		for (anim_map_t::value_type anim_pair : mAnimMap)
+		for (anim_map_t::value_type& anim_pair : mAnimMap)
 		{
 			if (anim_pair.second == true_name)
 			{
diff --git a/indra/llcharacter/llbvhloader.cpp b/indra/llcharacter/llbvhloader.cpp
index 70f6c0c4c9..47c6d6a7bb 100644
--- a/indra/llcharacter/llbvhloader.cpp
+++ b/indra/llcharacter/llbvhloader.cpp
@@ -156,7 +156,7 @@ LLBVHLoader::LLBVHLoader(const char* buffer, ELoadStatus &loadStatus, S32 &error
 	}
     
     // Recognize all names we've been told are legal.
-    for (std::map<std::string, std::string>::value_type alias_pair : joint_alias_map)
+    for (std::map<std::string, std::string>::value_type& alias_pair : joint_alias_map)
     {
         makeTranslation( alias_pair.first , alias_pair.second );
     }
diff --git a/indra/llcharacter/llcharacter.h b/indra/llcharacter/llcharacter.h
index bc0c2ec0d3..6d56d59e8c 100644
--- a/indra/llcharacter/llcharacter.h
+++ b/indra/llcharacter/llcharacter.h
@@ -218,7 +218,7 @@ public:
 	S32 getVisualParamCountInGroup(const EVisualParamGroup group) const
 	{
 		S32 rtn = 0;
-		for (visual_param_index_map_t::value_type index_pair : mVisualParamIndexMap)
+		for (const visual_param_index_map_t::value_type& index_pair : mVisualParamIndexMap)
 		{
 			if (index_pair.second->getGroup() == group)
 			{
@@ -235,7 +235,7 @@ public:
 	}
 	S32 getVisualParamID(LLVisualParam *id)
 	{
-		for (visual_param_index_map_t::value_type index_pair : mVisualParamIndexMap)
+		for (visual_param_index_map_t::value_type& index_pair : mVisualParamIndexMap)
 		{
 			if (index_pair.second == id)
 				return index_pair.first;
diff --git a/indra/llcharacter/llgesture.cpp b/indra/llcharacter/llgesture.cpp
index e9a4475707..80717d8d26 100644
--- a/indra/llcharacter/llgesture.cpp
+++ b/indra/llcharacter/llgesture.cpp
@@ -200,7 +200,7 @@ BOOL LLGestureList::triggerAndReviseString(const std::string &string, std::strin
 	boost::char_separator<char> sep(" ");
 	tokenizer tokens(string, sep);
 
-	for(std::string cur_token : tokens)
+	for(const std::string& cur_token : tokens)
 	{
 		LLGesture* gesture = NULL;
 
diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp
index 282db5c88b..280641a1a5 100644
--- a/indra/llcharacter/lljoint.cpp
+++ b/indra/llcharacter/lljoint.cpp
@@ -67,7 +67,7 @@ void LLVector3OverrideMap::showJointVector3Overrides( std::ostringstream& os ) c
 	map_type::const_iterator max_it = std::max_element(m_map.begin(),
 													   m_map.end(),
 													   attachment_map_iter_compare_key<map_type::value_type>);
-	for (const map_type::value_type pos_pair : m_map)
+	for (const map_type::value_type& pos_pair : m_map)
 	{
 		const LLVector3& pos = pos_pair.second;
 		os << " " << "[" << pos_pair.first <<": " << pos << "]" << ((pos_pair==(*max_it)) ? "*" : "");
@@ -509,7 +509,7 @@ void LLJoint::getAllAttachmentPosOverrides(S32& num_pos_overrides,
                                            std::set<LLVector3>& distinct_pos_overrides) const
 {
     num_pos_overrides = m_attachmentPosOverrides.count();
-    for (LLVector3OverrideMap::map_type::value_type pos_override_pair : m_attachmentPosOverrides.getMap())
+    for (const LLVector3OverrideMap::map_type::value_type& pos_override_pair : m_attachmentPosOverrides.getMap())
     {
         distinct_pos_overrides.insert(pos_override_pair.second);
     }
@@ -522,7 +522,7 @@ void LLJoint::getAllAttachmentScaleOverrides(S32& num_scale_overrides,
                                              std::set<LLVector3>& distinct_scale_overrides) const
 {
     num_scale_overrides = m_attachmentScaleOverrides.count();
-    for (LLVector3OverrideMap::map_type::value_type scale_override_pair : m_attachmentScaleOverrides.getMap())
+    for (const LLVector3OverrideMap::map_type::value_type& scale_override_pair : m_attachmentScaleOverrides.getMap())
     {
         distinct_scale_overrides.insert(scale_override_pair.second);
     }
@@ -549,7 +549,7 @@ void LLJoint::showAttachmentPosOverrides(const std::string& av_info) const
     {
         LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " has " << count << " attachment pos overrides" << LL_ENDL;
 		std::set<LLVector3> distinct_offsets;
-        for (LLVector3OverrideMap::map_type::value_type pos_override_pair : m_attachmentPosOverrides.getMap())
+        for (const LLVector3OverrideMap::map_type::value_type& pos_override_pair : m_attachmentPosOverrides.getMap())
         {
             distinct_offsets.insert(pos_override_pair.second);
         }
@@ -708,7 +708,7 @@ void LLJoint::showAttachmentScaleOverrides(const std::string& av_info) const
     {
         LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " has " << count << " attachment scale overrides" << LL_ENDL;
 		std::set<LLVector3> distinct_offsets;
-        for (LLVector3OverrideMap::map_type::value_type scale_override_pair : m_attachmentScaleOverrides.getMap())
+        for (const LLVector3OverrideMap::map_type::value_type& scale_override_pair : m_attachmentScaleOverrides.getMap())
         {
             distinct_offsets.insert(scale_override_pair.second);
         }
diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp
index 04c1475161..d82ce23b4b 100644
--- a/indra/llcharacter/llkeyframemotion.cpp
+++ b/indra/llcharacter/llkeyframemotion.cpp
@@ -1999,7 +1999,7 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
 		success &= dp.packS32(joint_motionp->mRotationCurve.mNumKeys, "num_rot_keys");
 
 		LL_DEBUGS("BVH") << "Joint " << joint_motionp->mJointName << LL_ENDL;
-		for (RotationCurve::key_map_t::value_type rot_pair : joint_motionp->mRotationCurve.mKeys)
+		for (RotationCurve::key_map_t::value_type& rot_pair : joint_motionp->mRotationCurve.mKeys)
 		{
 			RotationKey& rot_key = rot_pair.second;
 			U16 time_short = F32_to_U16(rot_key.mTime, 0.f, mJointMotionList->mDuration);
@@ -2020,7 +2020,7 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
 		}
 
 		success &= dp.packS32(joint_motionp->mPositionCurve.mNumKeys, "num_pos_keys");
-		for (PositionCurve::key_map_t::value_type pos_pair : joint_motionp->mPositionCurve.mKeys)
+		for (PositionCurve::key_map_t::value_type& pos_pair : joint_motionp->mPositionCurve.mKeys)
 		{
 			PositionKey& pos_key = pos_pair.second;
 			U16 time_short = F32_to_U16(pos_key.mTime, 0.f, mJointMotionList->mDuration);
@@ -2394,7 +2394,7 @@ void LLKeyframeDataCache::dumpDiagInfo()
 	LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
 
 	// print each loaded mesh, and it's memory usage
-	for (keyframe_data_map_t::value_type data_pair : sKeyframeDataMap)
+	for (keyframe_data_map_t::value_type& data_pair : sKeyframeDataMap)
 	{
 		U32 joint_motion_kb;
 
diff --git a/indra/llcharacter/llkeyframemotionparam.cpp b/indra/llcharacter/llkeyframemotionparam.cpp
index fce445fee7..c80aabe294 100644
--- a/indra/llcharacter/llkeyframemotionparam.cpp
+++ b/indra/llcharacter/llkeyframemotionparam.cpp
@@ -64,7 +64,7 @@ LLKeyframeMotionParam::LLKeyframeMotionParam( const LLUUID &id) : LLMotion(id)
 //-----------------------------------------------------------------------------
 LLKeyframeMotionParam::~LLKeyframeMotionParam()
 {
-	for (motion_map_t::value_type motion_pair : mParameterizedMotions)
+	for (motion_map_t::value_type& motion_pair : mParameterizedMotions)
 	{
 		motion_list_t& motionList = motion_pair.second;
 		for (const ParameterizedMotion& paramMotion : motionList)
@@ -88,7 +88,7 @@ LLMotion::LLMotionInitStatus LLKeyframeMotionParam::onInitialize(LLCharacter *ch
 		return STATUS_FAILURE;	
 	}
 	
-	for (motion_map_t::value_type motion_pair : mParameterizedMotions)
+	for (motion_map_t::value_type& motion_pair : mParameterizedMotions)
 	{
 		motion_list_t& motionList = motion_pair.second;
 		for (const ParameterizedMotion& paramMotion : motionList)
@@ -135,7 +135,7 @@ LLMotion::LLMotionInitStatus LLKeyframeMotionParam::onInitialize(LLCharacter *ch
 //-----------------------------------------------------------------------------
 BOOL LLKeyframeMotionParam::onActivate()
 {
-	for (motion_map_t::value_type motion_pair : mParameterizedMotions)
+	for (motion_map_t::value_type& motion_pair : mParameterizedMotions)
 	{
 		motion_list_t& motionList = motion_pair.second;
 		for (const ParameterizedMotion& paramMotion : motionList)
@@ -156,7 +156,7 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask)
 	F32 weightFactor = 1.f / (F32)mParameterizedMotions.size();
 
 	// zero out all pose weights
-	for (motion_map_t::value_type motion_pair : mParameterizedMotions)
+	for (motion_map_t::value_type& motion_pair : mParameterizedMotions)
 	{
 		motion_list_t& motionList = motion_pair.second;
 		for (const ParameterizedMotion& paramMotion : motionList)
@@ -167,7 +167,7 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask)
 	}
 
 
-	for (motion_map_t::value_type motion_pair : mParameterizedMotions)
+	for (motion_map_t::value_type& motion_pair : mParameterizedMotions)
 	{
 		const std::string& paramName = motion_pair.first;
 		F32* paramValue = (F32 *)mCharacter->getAnimationData(paramName);
@@ -270,7 +270,7 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask)
 //-----------------------------------------------------------------------------
 void LLKeyframeMotionParam::onDeactivate()
 {
-	for (motion_map_t::value_type motion_pair : mParameterizedMotions)
+	for (motion_map_t::value_type& motion_pair : mParameterizedMotions)
 	{
 		motion_list_t& motionList = motion_pair.second;
 		for (const ParameterizedMotion& paramMotion : motionList)
@@ -306,7 +306,7 @@ BOOL LLKeyframeMotionParam::addKeyframeMotion(char *name, const LLUUID &id, char
 //-----------------------------------------------------------------------------
 void LLKeyframeMotionParam::setDefaultKeyframeMotion(char *name)
 {
-	for (motion_map_t::value_type motion_pair : mParameterizedMotions)
+	for (motion_map_t::value_type& motion_pair : mParameterizedMotions)
 	{
 		motion_list_t& motionList = motion_pair.second;
 		for (const ParameterizedMotion& paramMotion : motionList)
diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp
index 8716fbff56..96e0d5e8d7 100644
--- a/indra/llcharacter/llmotioncontroller.cpp
+++ b/indra/llcharacter/llmotioncontroller.cpp
@@ -1053,7 +1053,7 @@ LLMotion* LLMotionController::findMotion(const LLUUID& id) const
 void LLMotionController::dumpMotions()
 {
 	LL_INFOS() << "=====================================" << LL_ENDL;
-	for (motion_map_t::value_type motion_pair : mAllMotions)
+	for (motion_map_t::value_type& motion_pair : mAllMotions)
 	{
 		LLUUID id = motion_pair.first;
 		std::string state_string;
@@ -1076,7 +1076,7 @@ void LLMotionController::dumpMotions()
 //-----------------------------------------------------------------------------
 void LLMotionController::deactivateAllMotions()
 {
-	for (motion_map_t::value_type motion_pair : mAllMotions)
+	for (motion_map_t::value_type& motion_pair : mAllMotions)
 	{
 		LLMotion* motionp = motion_pair.second;
 		deactivateMotionInstance(motionp);
@@ -1110,7 +1110,7 @@ void LLMotionController::flushAllMotions()
 	mCharacter->removeAnimationData("Hand Pose");
 
 	// restart motions
-	for (std::vector<std::pair<LLUUID,F32> >::value_type motion_pair : active_motions)
+	for (std::vector<std::pair<LLUUID,F32> >::value_type& motion_pair : active_motions)
 	{
 		startMotion(motion_pair.first, motion_pair.second);
 	}
diff --git a/indra/llcharacter/llpose.cpp b/indra/llcharacter/llpose.cpp
index a7156a250b..6f41a0e747 100644
--- a/indra/llcharacter/llpose.cpp
+++ b/indra/llcharacter/llpose.cpp
@@ -148,7 +148,7 @@ LLJointState* LLPose::findJointState(const std::string &name)
 void LLPose::setWeight(F32 weight)
 {
 	joint_map_iterator iter;
-	for (joint_map_value_type joint_pair : mJointMap)
+	for (joint_map_value_type& joint_pair : mJointMap)
 	{
 		joint_pair.second->setWeight(weight);
 	}
diff --git a/indra/llcharacter/llstatemachine.cpp b/indra/llcharacter/llstatemachine.cpp
index 320381e91e..2e8214ffaf 100644
--- a/indra/llcharacter/llstatemachine.cpp
+++ b/indra/llcharacter/llstatemachine.cpp
@@ -169,7 +169,7 @@ void LLStateDiagram::setDefaultState(LLFSMState& default_state)
 S32 LLStateDiagram::numDeadendStates()
 {
 	S32 numDeadends = 0;
-	for (StateMap::value_type state_pair : mStates)
+	for (StateMap::value_type& state_pair : mStates)
 	{
 		if (state_pair.second.size() == 0)
 		{
@@ -190,7 +190,7 @@ BOOL LLStateDiagram::stateIsValid(LLFSMState& state)
 
 LLFSMState* LLStateDiagram::getState(U32 state_id)
 {
-	for (StateMap::value_type state_pair : mStates)
+	for (StateMap::value_type& state_pair : mStates)
 	{
 		if (state_pair.first->getID() == state_id)
 		{
@@ -213,13 +213,13 @@ BOOL LLStateDiagram::saveDotFile(const std::string& filename)
 	}
 	apr_file_printf(dot_file, "digraph StateMachine {\n\tsize=\"100,100\";\n\tfontsize=40;\n\tlabel=\"Finite State Machine\";\n\torientation=landscape\n\tratio=.77\n");
 	
-	for (StateMap::value_type state_pair : mStates)
+	for (StateMap::value_type& state_pair : mStates)
 	{
 		apr_file_printf(dot_file, "\t\"%s\" [fontsize=28,shape=box]\n", state_pair.first->getName().c_str());
 	}
 	apr_file_printf(dot_file, "\t\"All States\" [fontsize=30,style=bold,shape=box]\n");
 
-	for (Transitions::value_type transition_pair : mDefaultTransitions)
+	for (Transitions::value_type& transition_pair : mDefaultTransitions)
 	{
 		apr_file_printf(dot_file, "\t\"All States\" -> \"%s\" [label = \"%s\",fontsize=24];\n", transition_pair.second->getName().c_str(),
 			transition_pair.second->getName().c_str());
@@ -231,11 +231,11 @@ BOOL LLStateDiagram::saveDotFile(const std::string& filename)
 	}
 
 	
-	for (StateMap::value_type state_pair : mStates)
+	for (StateMap::value_type& state_pair : mStates)
 	{
 		LLFSMState *state = state_pair.first;
 
-		for (Transitions::value_type transition_pair : state_pair.second)
+		for (Transitions::value_type& transition_pair : state_pair.second)
 		{
 			std::string state_name = state->getName();
 			std::string target_name = transition_pair.second->getName();
@@ -258,15 +258,15 @@ std::ostream& operator<<(std::ostream &s, LLStateDiagram &FSM)
 		s << "Default State: " << FSM.mDefaultState->getName() << "\n";
 	}
 
-	for (LLStateDiagram::Transitions::value_type transition_pair : FSM.mDefaultTransitions)
+	for (LLStateDiagram::Transitions::value_type& transition_pair : FSM.mDefaultTransitions)
 	{
 		s << "Any State -- " << transition_pair.first->getName()
 			<< " --> " << transition_pair.second->getName() << "\n";
 	}
 
-	for (LLStateDiagram::StateMap::value_type state_pair : FSM.mStates)
+	for (LLStateDiagram::StateMap::value_type& state_pair : FSM.mStates)
 	{
-		for (LLStateDiagram::Transitions::value_type transition_pair : state_pair.second)
+		for (LLStateDiagram::Transitions::value_type& transition_pair : state_pair.second)
 		{
 			s << state_pair.first->getName() << " -- " << transition_pair.first->getName()
 				<< " --> " << transition_pair.second->getName() << "\n";
-- 
cgit v1.2.3


From 8ec8732ec9a6dd109b3d40762148f0c951566e9b Mon Sep 17 00:00:00 2001
From: Andrey Lihatskiy <alihatskiy@productengine.com>
Date: Mon, 16 Jan 2023 23:07:51 +0200
Subject: SL-18893 OSX buildfix

---
 indra/llcharacter/llbvhloader.cpp | 2 --
 indra/llcharacter/lljoint.cpp     | 1 -
 2 files changed, 3 deletions(-)

(limited to 'indra/llcharacter')

diff --git a/indra/llcharacter/llbvhloader.cpp b/indra/llcharacter/llbvhloader.cpp
index 47c6d6a7bb..117d408b21 100644
--- a/indra/llcharacter/llbvhloader.cpp
+++ b/indra/llcharacter/llbvhloader.cpp
@@ -949,7 +949,6 @@ ELoadStatus LLBVHLoader::loadBVHFile(const char *buffer, char* error_text, S32 &
 //------------------------------------------------------------------------
 void LLBVHLoader::applyTranslations()
 {
-	JointVector::iterator ji;
 	for (Joint* joint : mJoints)
 	{
 		//----------------------------------------------------------------
@@ -1064,7 +1063,6 @@ void LLBVHLoader::optimize()
 		mEaseOut *= factor;
 	}
 
-	JointVector::iterator ji;
 	for (Joint* joint : mJoints)
 	{
 		BOOL pos_changed = FALSE;
diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp
index 280641a1a5..06f3bedf85 100644
--- a/indra/llcharacter/lljoint.cpp
+++ b/indra/llcharacter/lljoint.cpp
@@ -720,7 +720,6 @@ void LLJoint::showAttachmentScaleOverrides(const std::string& av_info) const
         {
             LL_DEBUGS("Avatar") << "no conflicts" << LL_ENDL;
         }
-        std::set<LLVector3>::iterator dit = distinct_offsets.begin();
         for (const LLVector3& offset : distinct_offsets)
         {
             std::string highlight = (has_active_override && offset == active_override) ? "*" : "";
-- 
cgit v1.2.3