From 7d721cfd3c1a66bfe22c740e11b9a0232d58da27 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Thu, 8 Jul 2021 13:20:37 -0400
Subject: [PATCH] Loop cleanup

---
 indra/newview/llagentcamera.cpp           | 13 ++---
 indra/newview/llagentwearables.cpp        | 13 ++---
 indra/newview/llappearancemgr.cpp         | 13 ++---
 indra/newview/llinventorybridge.cpp       |  8 ++-
 indra/newview/llsidepanelappearance.cpp   | 12 ++---
 indra/newview/llviewerattachmenu.cpp      | 19 +++----
 indra/newview/llviewerjointattachment.cpp | 62 +++++++----------------
 indra/newview/llviewermenu.cpp            | 39 +++++---------
 indra/newview/llviewerobjectlist.cpp      | 16 ++----
 indra/newview/rlvhelper.cpp               | 14 +++--
 indra/newview/rlvinventory.cpp            | 11 ++--
 indra/newview/rlvlocks.cpp                | 44 +++++++---------
 12 files changed, 90 insertions(+), 174 deletions(-)

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 76e9f6b10c3..3af05684363 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1588,16 +1588,11 @@ void LLAgentCamera::updateCamera()
 
 		gAgentAvatarp->mRoot->updateWorldMatrixChildren();
 
-		for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
-			 iter != gAgentAvatarp->mAttachmentPoints.end(); )
-		{
-			LLVOAvatar::attachment_map_t::iterator curiter = iter++;
-			LLViewerJointAttachment* attachment = curiter->second;
-			for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
-				 attachment_iter != attachment->mAttachedObjects.end();
-				 ++attachment_iter)
+		for (auto& attach_point_pair : gAgentAvatarp->mAttachmentPoints)
+		{
+            LLViewerJointAttachment* attachment = attach_point_pair.second;
+            for (LLViewerObject* attached_object : attachment->mAttachedObjects)
 			{
-				LLViewerObject *attached_object = attachment_iter->get();
 				if (attached_object && !attached_object->isDead() && attached_object->mDrawable.notNull())
 				{
 					// clear any existing "early" movements of attachment
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index cd021156090..8544f50555f 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -1346,16 +1346,11 @@ void LLAgentWearables::findAttachmentsAddRemoveInfo(LLInventoryModel::item_array
 	}
 
 	// Build up list of objects to be removed and items currently attached.
-	for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
-		 iter != gAgentAvatarp->mAttachmentPoints.end();)
-	{
-		LLVOAvatar::attachment_map_t::iterator curiter = iter++;
-		LLViewerJointAttachment* attachment = curiter->second;
-		for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
-			 attachment_iter != attachment->mAttachedObjects.end();
-			 ++attachment_iter)
+	for (const auto& attach_pair : gAgentAvatarp->mAttachmentPoints)
+	{
+        LLViewerJointAttachment* attachment = attach_pair.second;
+        for (LLViewerObject* objectp : attachment->mAttachedObjects)
 		{
-			LLViewerObject *objectp = attachment_iter->get();
 			if (objectp)
 			{
 				LLUUID object_item_id = objectp->getAttachmentItemID();
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index b2ffccb2450..d8f1abacf48 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -3253,16 +3253,11 @@ void LLAppearanceMgr::removeAllAttachmentsFromAvatar()
 
 	LLAgentWearables::llvo_vec_t objects_to_remove;
 	
-	for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
-		 iter != gAgentAvatarp->mAttachmentPoints.end();)
-	{
-		LLVOAvatar::attachment_map_t::iterator curiter = iter++;
-		LLViewerJointAttachment* attachment = curiter->second;
-		for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
-			 attachment_iter != attachment->mAttachedObjects.end();
-			 ++attachment_iter)
+	for (const auto attach_pair : gAgentAvatarp->mAttachmentPoints)
+	{
+        LLViewerJointAttachment* attachment = attach_pair.second;
+        for (LLViewerObject * attached_object : attachment->mAttachedObjects)
 		{
-			LLViewerObject *attached_object = attachment_iter->get();
 			if (attached_object)
 			{
 				objects_to_remove.push_back(attached_object);
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 96944905fcc..6a17c84be81 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -6715,11 +6715,9 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 					&& (attach_hud_menu->getChildCount() == 0)
 					&& isAgentAvatarValid())
 				{
-					for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin();
-						 iter != gAgentAvatarp->mAttachmentPoints.end(); )
+					for (const auto& attach_pair : gAgentAvatarp->mAttachmentPoints)
 					{
-						LLVOAvatar::attachment_map_t::iterator curiter = iter++;
-						LLViewerJointAttachment* attachment = curiter->second;
+                        LLViewerJointAttachment* attachment = attach_pair.second;
 						LLMenuItemCallGL::Params p;
 						std::string submenu_name = attachment->getName();
 						if (LLTrans::getString(submenu_name) != "")
@@ -6731,7 +6729,7 @@ void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 							p.name = submenu_name;
 						}
 						LLSD cbparams;
-						cbparams["index"] = curiter->first;
+						cbparams["index"] = attach_pair.first;
 						cbparams["label"] = p.name;
 						p.on_click.function_name = "Inventory.AttachObject";
 						p.on_click.parameter = LLSD(attachment->getName());
diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp
index 85feae32c34..078ebbec3e6 100644
--- a/indra/newview/llsidepanelappearance.cpp
+++ b/indra/newview/llsidepanelappearance.cpp
@@ -494,16 +494,12 @@ void LLSidepanelAppearance::fetchInventory()
 
 	if (isAgentAvatarValid())
 	{
-		for (LLVOAvatar::attachment_map_t::const_iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
-			 iter != gAgentAvatarp->mAttachmentPoints.end(); ++iter)
+		for (const auto& attach_pair : gAgentAvatarp->mAttachmentPoints)
 		{
-			LLViewerJointAttachment* attachment = iter->second;
+            LLViewerJointAttachment* attachment = attach_pair.second;
 			if (!attachment) continue;
-			for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
-				 attachment_iter != attachment->mAttachedObjects.end();
-				 ++attachment_iter)
-			{
-				LLViewerObject* attached_object = attachment_iter->get();
+            for (LLViewerObject* attached_object : attachment->mAttachedObjects)
+            {
 				if (!attached_object) continue;
 				const LLUUID& item_id = attached_object->getAttachmentItemID();
 				if (item_id.isNull()) continue;
diff --git a/indra/newview/llviewerattachmenu.cpp b/indra/newview/llviewerattachmenu.cpp
index 2d015fc8c1f..261232cecdc 100644
--- a/indra/newview/llviewerattachmenu.cpp
+++ b/indra/newview/llviewerattachmenu.cpp
@@ -58,11 +58,9 @@ void LLViewerAttachMenu::populateMenus(const std::string& attach_to_menu_name, c
 	}
 
 	// Populate "Attach to..." / "Attach to HUD..." submenus.
-	for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin();
-		 iter != gAgentAvatarp->mAttachmentPoints.end(); )
+	for (const auto& attach_pair : gAgentAvatarp->mAttachmentPoints)
 	{
-		LLVOAvatar::attachment_map_t::iterator curiter = iter++;
-		LLViewerJointAttachment* attachment = curiter->second;
+        LLViewerJointAttachment* attachment = attach_pair.second;
 		LLMenuItemCallGL::Params p;
 		std::string submenu_name = attachment->getName();
 		std::string translated_submenu_name;
@@ -77,7 +75,7 @@ void LLViewerAttachMenu::populateMenus(const std::string& attach_to_menu_name, c
 		}
 
 		LLSD cbparams;
-		cbparams["index"] = curiter->first;
+		cbparams["index"] = attach_pair.first;
 		cbparams["label"] = p.name;
 		p.on_click.function_name = "Object.Attach";
 		p.on_click.parameter = LLSD(attachment->getName());
@@ -94,11 +92,9 @@ void LLViewerAttachMenu::populateMenus(const std::string& attach_to_menu_name, c
 void LLViewerAttachMenu::attachObjects(const uuid_vec_t& items, const std::string& joint_name)
 {
 	LLViewerJointAttachment* attachmentp = NULL;
-	for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
-		 iter != gAgentAvatarp->mAttachmentPoints.end(); )
-	{
-		LLVOAvatar::attachment_map_t::iterator curiter = iter++;
-		LLViewerJointAttachment* attachment = curiter->second;
+    for (const auto& attach_pair : gAgentAvatarp->mAttachmentPoints)
+    {
+        LLViewerJointAttachment* attachment = attach_pair.second;
 		if (attachment->getName() == joint_name)
 		{
 			attachmentp = attachment;
@@ -110,9 +106,8 @@ void LLViewerAttachMenu::attachObjects(const uuid_vec_t& items, const std::strin
 		return;
 	}
 
-	for (uuid_vec_t::const_iterator it = items.begin(); it != items.end(); ++it)
+	for (const LLUUID& id : items)
 	{
-		const LLUUID &id = *it;
 		LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getLinkedItem(id);
 		if(item && gInventory.isObjectDescendentOf(id, gInventory.getRootFolderID()))
 		{
diff --git a/indra/newview/llviewerjointattachment.cpp b/indra/newview/llviewerjointattachment.cpp
index 738045b8db3..eecde439a57 100644
--- a/indra/newview/llviewerjointattachment.cpp
+++ b/indra/newview/llviewerjointattachment.cpp
@@ -252,11 +252,8 @@ BOOL LLViewerJointAttachment::addObject(LLViewerObject* object)
 void LLViewerJointAttachment::removeObject(LLViewerObject *object)
 {
 	attachedobjs_vec_t::iterator iter;
-	for (iter = mAttachedObjects.begin();
-		 iter != mAttachedObjects.end();
-		 ++iter)
-	{
-		LLViewerObject *attached_object = iter->get();
+    for (LLViewerObject* attached_object : mAttachedObjects)
+    {
 		if (attached_object == object)
 		{
 			break;
@@ -354,11 +351,8 @@ void LLViewerJointAttachment::removeObject(LLViewerObject *object)
 //-----------------------------------------------------------------------------
 void LLViewerJointAttachment::setAttachmentVisibility(BOOL visible)
 {
-	for (attachedobjs_vec_t::const_iterator iter = mAttachedObjects.begin();
-		 iter != mAttachedObjects.end();
-		 ++iter)
+    for (LLViewerObject* attached_obj : mAttachedObjects)
 	{
-		LLViewerObject *attached_obj = iter->get();
 		if (!attached_obj || attached_obj->mDrawable.isNull() || 
 			!(attached_obj->mDrawable->getSpatialBridge()))
 			continue;
@@ -393,11 +387,8 @@ void LLViewerJointAttachment::setOriginalPosition(LLVector3& position)
 S32 LLViewerJointAttachment::getNumAnimatedObjects() const
 {
     S32 count = 0;
-	for (attachedobjs_vec_t::const_iterator iter = mAttachedObjects.begin();
-		 iter != mAttachedObjects.end();
-		 ++iter)
-	{
-        const LLViewerObject *attached_object = iter->get();
+    for (LLViewerObject* attached_object : mAttachedObjects)
+    {
         if (attached_object->isAnimatedObject())
         {
             count++;
@@ -411,11 +402,9 @@ S32 LLViewerJointAttachment::getNumAnimatedObjects() const
 //-----------------------------------------------------------------------------
 void LLViewerJointAttachment::clampObjectPosition()
 {
-	for (attachedobjs_vec_t::const_iterator iter = mAttachedObjects.begin();
-		 iter != mAttachedObjects.end();
-		 ++iter)
-	{
-		if (LLViewerObject *attached_object = iter->get())
+    for (LLViewerObject* attached_object : mAttachedObjects)
+    {
+        if (attached_object)
 		{
 			// *NOTE: object can drift when hitting maximum radius
 			LLVector3 attachmentPos = attached_object->getPosition();
@@ -433,18 +422,14 @@ void LLViewerJointAttachment::clampObjectPosition()
 void LLViewerJointAttachment::calcLOD()
 {
 	F32 maxarea = 0;
-	for (attachedobjs_vec_t::const_iterator iter = mAttachedObjects.begin();
-		 iter != mAttachedObjects.end();
-		 ++iter)
-	{
-		if (LLViewerObject *attached_object = iter->get())
+    for (LLViewerObject* attached_object : mAttachedObjects)
+    {
+        if (attached_object)
 		{
 			maxarea = llmax(maxarea,attached_object->getMaxScale() * attached_object->getMidScale());
 			LLViewerObject::const_child_list_t& child_list = attached_object->getChildren();
-			for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
-				 iter != child_list.end(); ++iter)
+            for (LLViewerObject* childp : child_list)
 			{
-				LLViewerObject* childp = *iter;
 				F32 area = childp->getMaxScale() * childp->getMidScale();
 				maxarea = llmax(maxarea, area);
 			}
@@ -472,11 +457,8 @@ BOOL LLViewerJointAttachment::updateLOD(F32 pixel_area, BOOL activate)
 
 BOOL LLViewerJointAttachment::isObjectAttached(const LLViewerObject *viewer_object) const
 {
-	for (attachedobjs_vec_t::const_iterator iter = mAttachedObjects.begin();
-		 iter != mAttachedObjects.end();
-		 ++iter)
-	{
-		const LLViewerObject* attached_object = iter->get();
+    for (const LLViewerObject* attached_object : mAttachedObjects)
+    {
 		if (attached_object == viewer_object)
 		{
 			return TRUE;
@@ -487,12 +469,9 @@ BOOL LLViewerJointAttachment::isObjectAttached(const LLViewerObject *viewer_obje
 
 const LLViewerObject *LLViewerJointAttachment::getAttachedObject(const LLUUID &object_id) const
 {
-	for (attachedobjs_vec_t::const_iterator iter = mAttachedObjects.begin();
-		 iter != mAttachedObjects.end();
-		 ++iter)
-	{
-		const LLViewerObject* attached_object = iter->get();
-//		if (attached_object->getAttachmentItemID() == object_id)
+    for (const LLViewerObject* attached_object : mAttachedObjects)
+    {
+        //		if (attached_object->getAttachmentItemID() == object_id)
 // [SL:KB] - Patch: Appearance-PhantomAttach | Checked: Catznip-5.0
 		if ( (attached_object->getAttachmentItemID() == object_id) && (!attached_object->isDead()) )
 // [/SL:KB]
@@ -505,11 +484,8 @@ const LLViewerObject *LLViewerJointAttachment::getAttachedObject(const LLUUID &o
 
 LLViewerObject *LLViewerJointAttachment::getAttachedObject(const LLUUID &object_id)
 {
-	for (attachedobjs_vec_t::iterator iter = mAttachedObjects.begin();
-		 iter != mAttachedObjects.end();
-		 ++iter)
-	{
-		LLViewerObject* attached_object = iter->get();
+    for (LLViewerObject* attached_object : mAttachedObjects)
+    {
 		if (attached_object->getAttachmentItemID() == object_id)
 		{
 			return attached_object;
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 7e13995c2b8..afdd79811d6 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -7134,12 +7134,9 @@ class LLAttachmentDetachFromPoint : public view_listener_t
 		if ( (attachment->getNumObjects() > 0) && ((!rlv_handler_t::isEnabled()) || (gRlvAttachmentLocks.canDetach(attachment))) )
 // [/RLVa:KB]
 		{
-			for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator iter = attachment->mAttachedObjects.begin();
-				 iter != attachment->mAttachedObjects.end();
-				 iter++)
-			{
-				LLViewerObject *attached_object = iter->get();
-// [RLVa:KB] - Checked: 2010-03-04 (RLVa-1.2.0a) | Added: RLVa-1.2.0a
+            for (LLViewerObject* attached_object : attachment->mAttachedObjects)
+            {
+                // [RLVa:KB] - Checked: 2010-03-04 (RLVa-1.2.0a) | Added: RLVa-1.2.0a
 				if ( (rlv_handler_t::isEnabled()) && (gRlvAttachmentLocks.isLockedAttachment(attached_object)) )
 					continue;
 				ids_to_remove.push_back(attached_object->getAttachmentItemID());
@@ -7168,11 +7165,8 @@ static bool onEnableAttachmentLabel(LLUICtrl* ctrl, const LLSD& data)
 		if (attachment)
 		{
 			label = data["label"].asString();
-			for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator attachment_iter = attachment->mAttachedObjects.begin();
-				 attachment_iter != attachment->mAttachedObjects.end();
-				 ++attachment_iter)
-			{
-				const LLViewerObject* attached_object = attachment_iter->get();
+            for (const LLViewerObject* attached_object : attachment->mAttachedObjects)
+            {
 				if (attached_object)
 				{
 					LLViewerInventoryItem* itemp = gInventory.getItem(attached_object->getAttachmentItemID());
@@ -7299,20 +7293,18 @@ class LLAttachmentEnableDrop : public view_listener_t
 
 			if (attachment)
 			{
-				for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
-					 attachment_iter != attachment->mAttachedObjects.end();
-					 ++attachment_iter)
-				{
+                for (LLViewerObject* attached_object : attachment->mAttachedObjects)
+                {
 					// make sure item is in your inventory (it could be a delayed attach message being sent from the sim)
 					// so check to see if the item is in the inventory already
-					item = gInventory.getItem(attachment_iter->get()->getAttachmentItemID());
+                    item = gInventory.getItem(attached_object->getAttachmentItemID());
 					if (!item)
 					{
 						// Item does not exist, make an observer to enable the pie menu 
 						// when the item finishes fetching worst case scenario 
 						// if a fetch is already out there (being sent from a slow sim)
 						// we refetch and there are 2 fetches
-						LLWornItemFetchedObserver* worn_item_fetched = new LLWornItemFetchedObserver((*attachment_iter)->getAttachmentItemID());		
+						LLWornItemFetchedObserver* worn_item_fetched = new LLWornItemFetchedObserver(attached_object->getAttachmentItemID());		
 						worn_item_fetched->startFetch();
 						gInventory.addObserver(worn_item_fetched);
 					}
@@ -7784,17 +7776,12 @@ void handle_dump_attachments(void*)
 {
 	if(!isAgentAvatarValid()) return;
 
-	for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
-		 iter != gAgentAvatarp->mAttachmentPoints.end(); )
+	for (const auto& attach_pair : gAgentAvatarp->mAttachmentPoints)
 	{
-		LLVOAvatar::attachment_map_t::iterator curiter = iter++;
-		LLViewerJointAttachment* attachment = curiter->second;
-		S32 key = curiter->first;
-		for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
-			 attachment_iter != attachment->mAttachedObjects.end();
-			 ++attachment_iter)
+        LLViewerJointAttachment* attachment = attach_pair.second;
+		S32 key = attach_pair.first;
+        for (LLViewerObject * attached_object : attachment->mAttachedObjects)
 		{
-			LLViewerObject *attached_object = attachment_iter->get();
 			BOOL visible = (attached_object != NULL &&
 							attached_object->mDrawable.notNull() && 
 							!attached_object->mDrawable->isRenderType(0));
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 8603b2351af..6c474c62edb 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -1958,25 +1958,19 @@ void LLViewerObjectList::generatePickList(LLCamera &camera)
 		// add all hud objects to pick list
 		if (isAgentAvatarValid())
 		{
-			for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
-				 iter != gAgentAvatarp->mAttachmentPoints.end(); )
+			for (const auto& attach_pair : gAgentAvatarp->mAttachmentPoints)
 			{
-				LLVOAvatar::attachment_map_t::iterator curiter = iter++;
-				LLViewerJointAttachment* attachment = curiter->second;
+                LLViewerJointAttachment* attachment = attach_pair.second;
 				if (attachment->getIsHUDAttachment())
 				{
-					for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
-						 attachment_iter != attachment->mAttachedObjects.end();
-						 ++attachment_iter)
+                    for (LLViewerObject * attached_object : attachment->mAttachedObjects)
 					{
-						if (LLViewerObject* attached_object = attachment_iter->get())
+						if (attached_object)
 						{
 							mSelectPickList.insert(attached_object);
 							LLViewerObject::const_child_list_t& child_list = attached_object->getChildren();
-							for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
-								 iter != child_list.end(); iter++)
+                            for (LLViewerObject* childp : child_list)
 							{
-								LLViewerObject* childp = *iter;
 								if (childp)
 								{
 									mSelectPickList.insert(childp);
diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp
index a96cbc93355..12cf12d5e95 100644
--- a/indra/newview/rlvhelper.cpp
+++ b/indra/newview/rlvhelper.cpp
@@ -1404,10 +1404,9 @@ bool RlvForceWear::isForceDetachable(const LLViewerObject* pAttachObj, bool fChe
 bool RlvForceWear::isForceDetachable(const LLViewerJointAttachment* pAttachPt, bool fCheckComposite /*=true*/, const LLUUID& idExcept /*=LLUUID::null*/)
 {
 	// Attachment point can be detached by an RLV command if there's at least one attachment that can be removed
-	for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin();
-			itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj)
-	{
-		if (isForceDetachable(*itAttachObj, fCheckComposite, idExcept))
+    for (LLViewerObject* pAttachObj : pAttachPt->mAttachedObjects)
+    {
+        if (isForceDetachable(pAttachObj, fCheckComposite, idExcept))
 			return true;
 	}
 	return false;
@@ -1442,10 +1441,9 @@ void RlvForceWear::forceDetach(const LLViewerObject* pAttachObj)
 // Checked: 2010-03-19 (RLVa-1.2.0a) | Added: RLVa-1.2.0a
 void RlvForceWear::forceDetach(const LLViewerJointAttachment* pAttachPt)
 {
-	for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin();
-			itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj)
-	{
-		forceDetach(*itAttachObj);
+    for (LLViewerObject* pAttachObj : pAttachPt->mAttachedObjects)
+    {
+        forceDetach(pAttachObj);
 	}
 }
 
diff --git a/indra/newview/rlvinventory.cpp b/indra/newview/rlvinventory.cpp
index c29a7f38636..5e592f74cff 100644
--- a/indra/newview/rlvinventory.cpp
+++ b/indra/newview/rlvinventory.cpp
@@ -174,16 +174,13 @@ void RlvInventory::fetchWornItems()
 	// Fetch all currently worn attachments
 	if (isAgentAvatarValid())
 	{
-		for (LLVOAvatar::attachment_map_t::const_iterator itAttachPt = gAgentAvatarp->mAttachmentPoints.begin(); 
-				itAttachPt != gAgentAvatarp->mAttachmentPoints.end(); ++itAttachPt)
+		for (const auto& attach_pair : gAgentAvatarp->mAttachmentPoints)
 		{
-			const LLViewerJointAttachment* pAttachPt = itAttachPt->second;
+            const LLViewerJointAttachment* pAttachPt = attach_pair.second;
 			if (pAttachPt)
 			{
-				for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin();
-					 itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj)
-				{
-					const LLViewerObject* pAttachObj = (*itAttachObj);
+                for (const LLViewerObject* pAttachObj : pAttachPt->mAttachedObjects)
+                {
 					if ( (pAttachObj) && (pAttachObj->getAttachmentItemID().notNull()) )
 						idItems.push_back(pAttachObj->getAttachmentItemID());
 				}
diff --git a/indra/newview/rlvlocks.cpp b/indra/newview/rlvlocks.cpp
index 4b94e34fdf5..cdfcaa9f703 100644
--- a/indra/newview/rlvlocks.cpp
+++ b/indra/newview/rlvlocks.cpp
@@ -242,10 +242,9 @@ bool RlvAttachmentLocks::canDetach(const LLViewerJointAttachment* pAttachPt, boo
 	//       fDetachAll == true  : return true  => all attachments are unlocked
 	if (pAttachPt)
 	{
-		for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin();
-				itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj)
-		{
-			if ( (fDetachAll) ^ (!isLockedAttachment(*itAttachObj)) )
+        for (LLViewerObject* pAttachObj : pAttachPt->mAttachedObjects)
+        {
+            if ((fDetachAll) ^ (!isLockedAttachment(pAttachObj)))
 				return !fDetachAll;
 		}
 	}
@@ -257,10 +256,9 @@ bool RlvAttachmentLocks::hasLockedAttachment(const LLViewerJointAttachment* pAtt
 {
 	if (pAttachPt)
 	{
-		for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin();
-				itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj)
-		{
-			if (isLockedAttachment(*itAttachObj))
+        for (LLViewerObject* pAttachObj : pAttachPt->mAttachedObjects)
+        {
+            if (isLockedAttachment(pAttachObj))
 				return true;
 		}
 	}
@@ -518,10 +516,8 @@ void RlvAttachmentLockWatchdog::detach(S32 idxAttachPt, const uuid_vec_t& idsAtt
 		return;
 
 	std::vector<const LLViewerObject*> attachObjs;
-	for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin();
-			itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj)
-	{
-		const LLViewerObject* pAttachObj = *itAttachObj;
+    for (const LLViewerObject* pAttachObj : pAttachPt->mAttachedObjects)
+    {
 		if (idsAttachObjExcept.end() == std::find(idsAttachObjExcept.begin(), idsAttachObjExcept.end(), pAttachObj->getID()))
 			attachObjs.push_back(pAttachObj);
 	}
@@ -598,15 +594,12 @@ void RlvAttachmentLockWatchdog::onAttach(const LLViewerObject* pAttachObj, const
 				else
 				{
 					// Iterate over all the current attachments and force detach any that shouldn't be there
-					for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin();
-							itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj)
-					{
-						const LLViewerObject* pAttachObj = *itAttachObj;
-
+                    for (const LLViewerObject* pAttachObjL : pAttachPt->mAttachedObjects)
+                    {
 						uuid_vec_t::iterator itAttach = 
-							std::find(itAttachPrev->second.begin(), itAttachPrev->second.end(), pAttachObj->getAttachmentItemID());
+							std::find(itAttachPrev->second.begin(), itAttachPrev->second.end(), pAttachObjL->getAttachmentItemID());
 						if (itAttach == itAttachPrev->second.end())
-							detach(pAttachObj);
+                            detach(pAttachObjL);
 						else
 							itAttachPrev->second.erase(itAttach);
 					}
@@ -779,23 +772,20 @@ void RlvAttachmentLockWatchdog::onWearAttachment(const LLUUID& idItem, ERlvWearM
 	//       o eWearAction == RLV_WEAR_REPLACE : examine whether the new attachment can indeed replace/detach the old one
 	RlvWearInfo infoWear(idItem, eWearAction);
 	RLV_ASSERT( (RLV_WEAR_ADD == eWearAction) || (RLV_WEAR_REPLACE == eWearAction) ); // One of the two, but never both
-	for (LLVOAvatar::attachment_map_t::const_iterator itAttachPt = gAgentAvatarp->mAttachmentPoints.begin(); 
-			itAttachPt != gAgentAvatarp->mAttachmentPoints.end(); ++itAttachPt)
+	for (const auto& attach_pair : gAgentAvatarp->mAttachmentPoints)
 	{
-		const LLViewerJointAttachment* pAttachPt = itAttachPt->second;
+        const LLViewerJointAttachment* pAttachPt = attach_pair.second;
 		// We only need to know which attachments were present for RLV_LOCK_ADD locked attachment points (and not RLV_LOCK_REM locked ones)
 		if (gRlvAttachmentLocks.isLockedAttachmentPoint(pAttachPt, RLV_LOCK_ADD))
 		{
 			uuid_vec_t attachObjs;
-			for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin();
-					itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj)
-			{
-				const LLViewerObject* pAttachObj = *itAttachObj;
+            for (const LLViewerObject* pAttachObj : pAttachPt->mAttachedObjects)
+            {
 				if (std::find(m_PendingDetach.begin(), m_PendingDetach.end(), pAttachObj->getAttachmentItemID()) != m_PendingDetach.end())
 					continue;	// Exclude attachments that are pending a force-detach
 				attachObjs.push_back(pAttachObj->getAttachmentItemID());
 			}
-			infoWear.attachPts.insert(std::pair<S32, uuid_vec_t>(itAttachPt->first, attachObjs));
+            infoWear.attachPts.insert(std::pair<S32, uuid_vec_t>(attach_pair.first, attachObjs));
 		}
 	}
 
-- 
GitLab