diff --git a/indra/newview/llfloaterimsession.cpp b/indra/newview/llfloaterimsession.cpp
index b1319d9c10012fb8e40e6f0079f4c423bb2421b6..81afd5bf7583c8d703f8df80a1d69f2a1bf2f064 100644
--- a/indra/newview/llfloaterimsession.cpp
+++ b/indra/newview/llfloaterimsession.cpp
@@ -1085,12 +1085,10 @@ void LLFloaterIMSession::processAgentListUpdates(const LLSD& body)
 	if (body.isMap() && body.has("agent_updates") && body["agent_updates"].isMap())
 	{
 		LLSD::map_const_iterator update_it;
-		for(update_it = body["agent_updates"].beginMap();
-			update_it != body["agent_updates"].endMap();
-			++update_it)
+		for(const auto& agent_update : body["agent_updates"].map())
 		{
-			LLUUID agent_id(update_it->first);
-			LLSD agent_data = update_it->second;
+			LLUUID agent_id(agent_update.first);
+			LLSD agent_data = agent_update.second;
 
 			if (agent_data.isMap())
 			{
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 4ea73ea4d953d4b88e61dd303591db4952a19228..4b156d505fd9f214c29b9dd2f0f8420de0adc0a5 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -3226,19 +3226,13 @@ void LLIMMgr::addPendingAgentListUpdates(
 		update_types.append("agent_updates");
 		update_types.append("updates");
 
-		for (
-			array_iter = update_types.beginArray();
-			array_iter != update_types.endArray();
-			++array_iter)
+		for (const auto& update_type : update_types.array())
 		{
 			//we only want to include the last update for a given agent
-			for (
-				iter = updates[array_iter->asString()].beginMap();
-				iter != updates[array_iter->asString()].endMap();
-				++iter)
+			for (const auto& update_pair : updates[update_type.asStringRef()].map())
 			{
-				mPendingAgentListUpdates[session_id.asString()][array_iter->asString()][iter->first] =
-					iter->second;
+				mPendingAgentListUpdates[session_id.asString()][array_iter->asString()][update_pair.first] =
+					update_pair.second;
 			}
 		}
 	}
@@ -3250,13 +3244,10 @@ void LLIMMgr::addPendingAgentListUpdates(
 		//of agent_id -> "LEAVE"/"ENTER"
 
 		//only want to keep last update for each agent
-		for (
-			iter = updates["updates"].beginMap();
-			iter != updates["updates"].endMap();
-			++iter)
+		for (const auto& update_pair : updates["updates"].map())
 		{
-			mPendingAgentListUpdates[session_id.asString()]["updates"][iter->first] =
-				iter->second;
+			mPendingAgentListUpdates[session_id.asString()]["updates"][update_pair.first] =
+				update_pair.second;
 		}
 	}
 }