From d7672f9fe78c4111cd98921a64e405f05dd1f5fc Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Fri, 3 Jan 2020 10:12:45 -0500
Subject: [PATCH] Various for loop cleanup, const ref cleanup, and other small
 maint work

---
 indra/newview/alviewermenu.cpp                |  4 +--
 indra/newview/llagent.cpp                     |  2 +-
 indra/newview/llagent.h                       |  2 +-
 indra/newview/llagentcamera.cpp               |  4 +--
 indra/newview/llagentcamera.h                 |  6 ++---
 indra/newview/llavatarlist.cpp                |  6 ++---
 indra/newview/llavatarlist.h                  |  2 +-
 .../newview/llavatarrenderinfoaccountant.cpp  | 11 ++++----
 indra/newview/llchatitemscontainerctrl.cpp    |  4 +--
 indra/newview/llchiclet.cpp                   |  3 +--
 indra/newview/llcompilequeue.cpp              |  2 +-
 indra/newview/llcontrolavatar.cpp             |  4 +--
 indra/newview/llconversationmodel.cpp         | 10 +++-----
 indra/newview/llconversationview.cpp          |  2 +-
 indra/newview/lldaycyclemanager.cpp           |  6 ++---
 indra/newview/lldaycyclemanager.h             |  6 ++---
 indra/newview/lleasymessagereader.cpp         |  4 +--
 indra/newview/lleasymessagereader.h           |  4 +--
 indra/newview/llenvmanager.h                  |  4 +--
 indra/newview/lleventnotifier.cpp             |  4 +--
 indra/newview/llfasttimerview.cpp             |  4 +--
 indra/newview/llfasttimerview.h               |  2 +-
 indra/newview/llfavoritesbar.cpp              |  2 +-
 .../newview/llfloaterautoreplacesettings.cpp  |  4 +--
 indra/newview/llfloatermodelpreview.cpp       |  4 +--
 indra/newview/llfloaterpreference.cpp         |  1 -
 indra/newview/llgroupmgr.h                    |  2 +-
 indra/newview/llmeshrepository.cpp            | 25 ++++++++++---------
 indra/newview/llmeshrepository.h              |  1 +
 indra/newview/lloutfitgallery.h               |  2 +-
 indra/newview/llsecapicerthandler.h           |  5 ++--
 indra/newview/llselectmgr.h                   |  4 +--
 indra/newview/llspatialpartition.h            |  2 +-
 indra/newview/llviewertexture.h               |  2 +-
 indra/newview/llviewertexturelist.h           |  2 +-
 indra/newview/llvoavatar.cpp                  |  2 +-
 indra/newview/llvoavatar.h                    |  2 +-
 indra/newview/llvovolume.cpp                  |  4 +--
 indra/newview/llvovolume.h                    |  4 +--
 indra/newview/llwaterparamset.h               |  4 +--
 indra/newview/llworld.h                       |  4 +--
 41 files changed, 85 insertions(+), 87 deletions(-)

diff --git a/indra/newview/alviewermenu.cpp b/indra/newview/alviewermenu.cpp
index 346a2c19c2..cce4bdc6ee 100644
--- a/indra/newview/alviewermenu.cpp
+++ b/indra/newview/alviewermenu.cpp
@@ -69,7 +69,7 @@ void al_handle_object_derender()
 	LLSelectMgr* select_mgr = LLSelectMgr::getInstance();
 	LLObjectSelectionHandle selection = select_mgr->getSelection();
 	std::vector<LLViewerObject*> objects;
-	for (LLObjectSelection::iterator iter = selection->begin(); iter != selection->end(); iter++)
+	for (LLObjectSelection::iterator iter = selection->begin(); iter != selection->end(); ++iter)
 	{
 		LLSelectNode* nodep = *iter;
 		if (!nodep)
@@ -124,7 +124,7 @@ class LLEnableEditParticleSource : public view_listener_t
 	{
 		LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
 		for (LLObjectSelection::valid_root_iterator iter = selection->valid_root_begin();
-			iter != selection->valid_root_end(); iter++)
+			iter != selection->valid_root_end(); ++iter)
 		{
 			LLSelectNode* node = *iter;
 			if (node->mPermissions->getOwner() == gAgent.getID())
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 02bf9a433b..d6ba90114b 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -2684,7 +2684,7 @@ bool LLAgent::canAccessMaturityInRegion( U64 region_handle ) const
 	return true;
 }
 
-bool LLAgent::canAccessMaturityAtGlobal( LLVector3d pos_global ) const
+bool LLAgent::canAccessMaturityAtGlobal(const LLVector3d& pos_global ) const
 {
 	U64 region_handle = to_region_handle_global( pos_global.mdV[0], pos_global.mdV[1] );
 	return canAccessMaturityInRegion( region_handle );
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index 6b622bd492..0d45a82c48 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -794,7 +794,7 @@ public:
 	bool 			canAccessMature() const;
 	bool 			canAccessAdult() const;
 	bool 			canAccessMaturityInRegion( U64 region_handle ) const;
-	bool 			canAccessMaturityAtGlobal( LLVector3d pos_global ) const;
+	bool 			canAccessMaturityAtGlobal( const LLVector3d& pos_global ) const;
 	bool 			prefersPG() const;
 	bool 			prefersMature() const;
 	bool 			prefersAdult() const;
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 5ba2235d06..970a369134 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -395,7 +395,7 @@ void LLAgentCamera::slamLookAt(const LLVector3 &look_at)
 //-----------------------------------------------------------------------------
 // calcFocusOffset()
 //-----------------------------------------------------------------------------
-LLVector3 LLAgentCamera::calcFocusOffset(LLViewerObject *object, LLVector3 original_focus_point, S32 x, S32 y) const
+LLVector3 LLAgentCamera::calcFocusOffset(LLViewerObject *object, const LLVector3& original_focus_point, S32 x, S32 y) const
 {
 	LLMatrix4 obj_matrix = object->getRenderMatrix();
 	LLQuaternion obj_rot = object->getRenderRotation();
@@ -2027,7 +2027,7 @@ bool LLAgentCamera::allowFocusOffsetChange(const LLVector3d& offsetFocus)
 	return true;
 }
 
-bool LLAgentCamera::clampCameraPosition(LLVector3d& posCamGlobal, const LLVector3d posCamRefGlobal, float nDistMin, float nDistMax)
+bool LLAgentCamera::clampCameraPosition(LLVector3d& posCamGlobal, const LLVector3d& posCamRefGlobal, float nDistMin, float nDistMax)
 {
 	const LLVector3d offsetCamera = posCamGlobal - posCamRefGlobal;
 
diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h
index 83b83d2273..1ab90242f2 100644
--- a/indra/newview/llagentcamera.h
+++ b/indra/newview/llagentcamera.h
@@ -204,7 +204,7 @@ private:
 	//--------------------------------------------------------------------
 public:
 	LLVector3d		calcFocusPositionTargetGlobal();
-	LLVector3		calcFocusOffset(LLViewerObject *object, LLVector3 pos_agent, S32 x, S32 y) const;
+	LLVector3		calcFocusOffset(LLViewerObject *object, const LLVector3& pos_agent, S32 x, S32 y) const;
 	BOOL			getFocusOnAvatar() const		{ return mFocusOnAvatar; }
 	LLPointer<LLViewerObject>&	getFocusObject() 	{ return mFocusObject; }
 	F32				getFocusObjectDist() const		{ return mFocusObjectDist; }
@@ -252,7 +252,7 @@ public:
 	//--------------------------------------------------------------------
 public:
 	LLVector3d		calcThirdPersonFocusOffset();
-	void			setThirdPersonHeadOffset(LLVector3 offset) 	{ mThirdPersonHeadOffset = offset; }	
+	void			setThirdPersonHeadOffset(const LLVector3& offset) 	{ mThirdPersonHeadOffset = offset; }	
 private:
 	LLVector3		mThirdPersonHeadOffset;						// Head offset for third person camera position
 
@@ -316,7 +316,7 @@ public:
 	//--------------------------------------------------------------------
 protected:
 	bool allowFocusOffsetChange(const LLVector3d& offsetFocus);
-	bool clampCameraPosition(LLVector3d& posCamGlobal, const LLVector3d posCamRefGlobal, float nDistMin, float nDistMax);
+	bool clampCameraPosition(LLVector3d& posCamGlobal, const LLVector3d& posCamRefGlobal, float nDistMin, float nDistMax);
 
 	bool m_fRlvMaxDist;				// True if the camera is at max distance
 	bool m_fRlvMinDist;				// True if the camera is at min distance
diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp
index c42d02137e..33c2a67657 100644
--- a/indra/newview/llavatarlist.cpp
+++ b/indra/newview/llavatarlist.cpp
@@ -180,11 +180,11 @@ LLAvatarList::~LLAvatarList()
 
 void LLAvatarList::setShowIcons(std::string param_name)
 {
-	mIconParamName= param_name;
+	mIconParamName = std::move(param_name);
 	mShowIcons = gSavedSettings.getBOOL(mIconParamName);
 }
 
-std::string LLAvatarList::getAvatarName(LLAvatarName av_name)
+std::string LLAvatarList::getAvatarName(const LLAvatarName& av_name)
 {
 	return mShowCompleteName? av_name.getCompleteName(false) : av_name.getDisplayName();
 }
@@ -691,7 +691,7 @@ BOOL LLAvalineListItem::postBuild()
 		setShowProfileBtn(false);
 		setShowInfoBtn(false);
 		mAvatarIcon->setValue("Avaline_Icon");
-		mAvatarIcon->setToolTip(std::string(""));
+		mAvatarIcon->setToolTip(std::string());
 	}
 	return rv;
 }
diff --git a/indra/newview/llavatarlist.h b/indra/newview/llavatarlist.h
index 4faf689bc7..f083ec7c8c 100644
--- a/indra/newview/llavatarlist.h
+++ b/indra/newview/llavatarlist.h
@@ -84,7 +84,7 @@ public:
 	void setShowIcons(std::string param_name);
 	bool getIconsVisible() const { return mShowIcons; }
 	const std::string getIconParamName() const {return mIconParamName;}
-	std::string getAvatarName(LLAvatarName av_name);
+	std::string getAvatarName(const LLAvatarName& av_name);
 	BOOL handleRightMouseDown(S32 x, S32 y, MASK mask) override;
 	BOOL handleMouseDown( S32 x, S32 y, MASK mask ) override;
 	BOOL handleMouseUp(S32 x, S32 y, MASK mask) override;
diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp
index 7602c79676..2088cdf0b9 100644
--- a/indra/newview/llavatarrenderinfoaccountant.cpp
+++ b/indra/newview/llavatarrenderinfoaccountant.cpp
@@ -105,9 +105,9 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(std::string url, U64
         const LLSD & agents = result[KEY_AGENTS];
         if (agents.isMap())
         {
-            for (LLSD::map_const_iterator agent_iter = agents.beginMap();
-                 agent_iter != agents.endMap();
-                 agent_iter++
+            for (LLSD::map_const_iterator agent_iter = agents.beginMap(), agent_iter_end = agents.endMap();
+                 agent_iter != agent_iter_end;
+                 ++agent_iter
                  )
             {
                 LLUUID target_agent_id = LLUUID(agent_iter->first);
@@ -209,10 +209,11 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(std::string url, U
         {
             avatar->calculateUpdateRenderComplexity();			// Make sure the numbers are up-to-date
 
-            LLSD info = LLSD::emptyMap();
             U32 avatar_complexity = avatar->getVisualComplexity();
             if (avatar_complexity > 0)
             {
+                LLSD info = LLSD::emptyMap();
+
                 // the weight/complexity is unsigned, but LLSD only stores signed integers,
                 // so if it's over that (which would be ridiculously high), just store the maximum signed int value
                 info[KEY_WEIGHT] = (S32)(avatar_complexity < S32_MAX ? avatar_complexity : S32_MAX);
@@ -224,7 +225,7 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(std::string url, U
                 num_avs++;
             }
         }
-        iter++;
+        ++iter;
     }
 
     // Reset this regions timer, moving to longer intervals if there are lots of avatars around
diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp
index 642473cfde..3b173dc461 100644
--- a/indra/newview/llchatitemscontainerctrl.cpp
+++ b/indra/newview/llchatitemscontainerctrl.cpp
@@ -280,8 +280,8 @@ void LLFloaterIMNearbyChatToastPanel::init(LLSD& notification)
 	int chars = 0;
 
 	//Remove excessive chars if message does not fit in available height. MAINT-6891
-	std::string::iterator it;
-	for (it = messageText.begin(); it < messageText.end() && lines < max_lines; it++)
+	std::string::iterator it = messageText.begin();
+	for (auto it_end = messageText.end(); it < it_end && lines < max_lines; ++it)
 	{
 		if (*it == '\n')
 			++lines;
diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp
index 3eb4701cea..5648ba5bb5 100644
--- a/indra/newview/llchiclet.cpp
+++ b/indra/newview/llchiclet.cpp
@@ -484,8 +484,7 @@ void LLChicletPanel::objectChicletCallback(const LLSD& data)
 	bool new_message = data["new_message"];
 
 	std::list<LLChiclet*> chiclets = LLIMChiclet::sFindChicletsSignal(notification_id);
-	std::list<LLChiclet *>::iterator iter;
-	for (iter = chiclets.begin(); iter != chiclets.end(); iter++)
+	for (auto iter = chiclets.begin(), iter_end = chiclets.end(); iter != iter_end; ++iter)
 	{
 		LLIMChiclet* chiclet = dynamic_cast<LLIMChiclet*>(*iter);
 		if (chiclet != nullptr)
diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp
index 89dce658fa..0fe99974df 100644
--- a/indra/newview/llcompilequeue.cpp
+++ b/indra/newview/llcompilequeue.cpp
@@ -494,7 +494,7 @@ bool LLFloaterCompileQueue::processScript(LLHandle<LLFloaterCompileQueue> hfloat
         std::string buffer = std::string("Compilation of \"") + inventory->getName() + std::string("\" failed:");
         floater->addStringMessage(buffer);
         for (LLSD::array_const_iterator line = compile_errors.beginArray();
-            line < compile_errors.endArray(); line++)
+            line < compile_errors.endArray(); ++line)
         {
             std::string str = line->asString();
             str.erase(std::remove(str.begin(), str.end(), '\n'), str.end());
diff --git a/indra/newview/llcontrolavatar.cpp b/indra/newview/llcontrolavatar.cpp
index a3e74a5dc0..f4ba0cb840 100644
--- a/indra/newview/llcontrolavatar.cpp
+++ b/indra/newview/llcontrolavatar.cpp
@@ -505,8 +505,8 @@ void LLControlAvatar::updateAnimations()
         LLVOVolume *volp = *vol_it;
         //LL_INFOS("AnimatedObjects") << "updating anim for vol " << volp->getID() << " root " << mRootVolp->getID() << LL_ENDL;
         signaled_animation_map_t& signaled_animations = LLObjectSignaledAnimationMap::instance().getMap()[volp->getID()];
-        for (auto anim_it = signaled_animations.begin();
-             anim_it != signaled_animations.end();
+        for (auto anim_it = signaled_animations.begin(), anim_it_end = signaled_animations.end();
+             anim_it != anim_it_end;
              ++anim_it)
         {
             auto found_anim_it = anims.find(anim_it->first);
diff --git a/indra/newview/llconversationmodel.cpp b/indra/newview/llconversationmodel.cpp
index 3cbecc064d..40b8567eb3 100644
--- a/indra/newview/llconversationmodel.cpp
+++ b/indra/newview/llconversationmodel.cpp
@@ -337,16 +337,15 @@ LLConversationItemParticipant* LLConversationItemSession::findParticipant(const
 	// This is *not* a general tree parsing algorithm. It assumes that a session contains only 
 	// items (LLConversationItemParticipant) that have themselve no children.
 	LLConversationItemParticipant* participant = nullptr;
-	child_list_t::iterator iter;
-	for (iter = mChildren.begin(); iter != mChildren.end(); iter++)
+	for (auto iter = mChildren.begin(), iter_end = mChildren.end(); iter != iter_end; ++iter)
 	{
 		participant = dynamic_cast<LLConversationItemParticipant*>(*iter);
 		if (participant->hasSameValue(participant_id))
 		{
-			break;
+			return (iter == mChildren.end() ? NULL : participant);
 		}
 	}
-	return (iter == mChildren.end() ? NULL : participant);
+	return nullptr;
 }
 
 void LLConversationItemSession::setParticipantIsMuted(const LLUUID& participant_id, bool is_muted)
@@ -449,8 +448,7 @@ bool LLConversationItemSession::getTime(F64& time) const
 	F64 most_recent_time = mLastActiveTime;
 	bool has_time = (most_recent_time > 0.1);
 	LLConversationItemParticipant* participant = nullptr;
-	child_list_t::const_iterator iter;
-	for (iter = mChildren.begin(); iter != mChildren.end(); iter++)
+	for (auto iter = mChildren.begin(), iter_end = mChildren.end(); iter != iter_end; ++iter)
 	{
 		participant = dynamic_cast<LLConversationItemParticipant*>(*iter);
 		F64 participant_time;
diff --git a/indra/newview/llconversationview.cpp b/indra/newview/llconversationview.cpp
index f4cc062ccb..1aa2f055a5 100644
--- a/indra/newview/llconversationview.cpp
+++ b/indra/newview/llconversationview.cpp
@@ -453,7 +453,7 @@ void LLConversationViewSession::refresh()
 	}
 
 	LLConversationViewParticipant* participant = nullptr;
-	for (auto iter = getItemsBegin(); iter != getItemsEnd(); iter++)
+	for (auto iter = getItemsBegin(); iter != getItemsEnd(); ++iter)
 	{
 		participant = dynamic_cast<LLConversationViewParticipant*>(*iter);
 		if (participant)
diff --git a/indra/newview/lldaycyclemanager.cpp b/indra/newview/lldaycyclemanager.cpp
index c91f8350cc..54584ad702 100644
--- a/indra/newview/lldaycyclemanager.cpp
+++ b/indra/newview/lldaycyclemanager.cpp
@@ -82,7 +82,7 @@ void LLDayCycleManager::getUserPresetNames(preset_name_list_t& user) const
 	getPresetNames(user, sys);
 }
 
-bool LLDayCycleManager::getPreset(const std::string name, LLWLDayCycle& day_cycle) const
+bool LLDayCycleManager::getPreset(const std::string& name, LLWLDayCycle& day_cycle) const
 {
 	dc_map_t::const_iterator it = mDayCycleMap.find(name);
 	if (it == mDayCycleMap.end())
@@ -94,7 +94,7 @@ bool LLDayCycleManager::getPreset(const std::string name, LLWLDayCycle& day_cycl
 	return true;
 }
 
-bool LLDayCycleManager::getPreset(const std::string name, LLSD& day_cycle) const
+bool LLDayCycleManager::getPreset(const std::string& name, LLSD& day_cycle) const
 {
 	LLWLDayCycle dc;
 	if (!getPreset(name, dc))
@@ -106,7 +106,7 @@ bool LLDayCycleManager::getPreset(const std::string name, LLSD& day_cycle) const
 	return true;
 }
 
-bool LLDayCycleManager::presetExists(const std::string name) const
+bool LLDayCycleManager::presetExists(const std::string& name) const
 {
 	LLWLDayCycle dummy;
 	return getPreset(name, dummy);
diff --git a/indra/newview/lldaycyclemanager.h b/indra/newview/lldaycyclemanager.h
index dab4f64589..aaa34680ff 100644
--- a/indra/newview/lldaycyclemanager.h
+++ b/indra/newview/lldaycyclemanager.h
@@ -53,9 +53,9 @@ public:
 	const std::string& findPreset(const std::string& strPresetName);
 // [/RLVa:KB]
 
-	bool getPreset(const std::string name, LLWLDayCycle& day_cycle) const;
-	bool getPreset(const std::string name, LLSD& day_cycle) const;
-	bool presetExists(const std::string name) const;
+	bool getPreset(const std::string& name, LLWLDayCycle& day_cycle) const;
+	bool getPreset(const std::string& name, LLSD& day_cycle) const;
+	bool presetExists(const std::string& name) const;
 	bool isSystemPreset(const std::string& name) const;
 	bool savePreset(const std::string& name, const LLSD& data);
 	bool deletePreset(const std::string& name);
diff --git a/indra/newview/lleasymessagereader.cpp b/indra/newview/lleasymessagereader.cpp
index b85cfaf3c5..43e20ed16b 100644
--- a/indra/newview/lleasymessagereader.cpp
+++ b/indra/newview/lleasymessagereader.cpp
@@ -31,13 +31,13 @@ LLEasyMessageReader::~LLEasyMessageReader()
 //we might want the sequenceid of the packet, which we can't get from
 //a messagetemplate pointer, allow for passing in a U32 to be replaced
 //with the sequenceid
-LLMessageTemplate* LLEasyMessageReader::decodeTemplateMessage(U8 *data, S32 data_len, LLHost const& from_host)
+LLMessageTemplate* LLEasyMessageReader::decodeTemplateMessage(U8 *data, S32 data_len, const LLHost& from_host)
 {
 	U32 fake_id = 0;
 	return decodeTemplateMessage(data, data_len, from_host, fake_id);
 }
 
-LLMessageTemplate* LLEasyMessageReader::decodeTemplateMessage(U8 *data, S32 data_len, LLHost from_host, U32& sequence_id)
+LLMessageTemplate* LLEasyMessageReader::decodeTemplateMessage(U8 *data, S32 data_len, const LLHost& from_host, U32& sequence_id)
 {
 	if(data_len > MAX_BUFFER_SIZE)
 	{
diff --git a/indra/newview/lleasymessagereader.h b/indra/newview/lleasymessagereader.h
index 506ce32176..2047906bb3 100644
--- a/indra/newview/lleasymessagereader.h
+++ b/indra/newview/lleasymessagereader.h
@@ -31,8 +31,8 @@ public:
 	LLEasyMessageReader();
 	~LLEasyMessageReader();
 
-	LLMessageTemplate* decodeTemplateMessage(U8* data, S32 data_len, LLHost const& from_host);
-	LLMessageTemplate* decodeTemplateMessage(U8* data, S32 data_len, LLHost from_host, U32& sequence_id);
+	LLMessageTemplate* decodeTemplateMessage(U8* data, S32 data_len, const LLHost& from_host);
+	LLMessageTemplate* decodeTemplateMessage(U8* data, S32 data_len, const LLHost& from_host, U32& sequence_id);
 
 	S32 getNumberOfBlocks(const char *blockname);
 
diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h
index d981a86adb..29b8dc15bd 100644
--- a/indra/newview/llenvmanager.h
+++ b/indra/newview/llenvmanager.h
@@ -106,7 +106,7 @@ public:
 		scope = EScope(llsd[SCOPE_IDX].asInteger());
 	}
 
-	inline bool operator <(const LLWLParamKey other) const
+	inline bool operator <(const LLWLParamKey& other) const
 	{
 		if (name < other.name)
 		{	
@@ -122,7 +122,7 @@ public:
 		}
 	}
 
-	inline bool operator ==(const LLWLParamKey other) const
+	inline bool operator ==(const LLWLParamKey& other) const
 	{
 		return (name == other.name) && (scope == other.scope);
 	}
diff --git a/indra/newview/lleventnotifier.cpp b/indra/newview/lleventnotifier.cpp
index 06b266d2a9..63aaab3e28 100644
--- a/indra/newview/lleventnotifier.cpp
+++ b/indra/newview/lleventnotifier.cpp
@@ -103,7 +103,7 @@ LLEventNotifier::~LLEventNotifier()
 
 	for (iter = mEventNotifications.begin();
 		 iter != mEventNotifications.end();
-		 iter++)
+		 ++iter)
 	{
 		delete iter->second;
 	}
@@ -124,7 +124,7 @@ void LLEventNotifier::update()
 		{
 			LLEventNotification *np = iter->second;
 
-			iter++;
+			++iter;
 			if (np->getEventDateEpoch() < alert_time)
 			{
 				LLSD args;
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 7c339dae83..de5c111c80 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -1630,9 +1630,9 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::BlockTimerStatHandle* time_b
 	return timer_bar_index;
 }
 
-S32 LLFastTimerView::drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered, bool visible, S32 bar_index)
+S32 LLFastTimerView::drawBar(const LLRect& bar_rect, const TimerBarRow& row, S32 image_width, S32 image_height, bool hovered, bool visible, S32 bar_index)
 {
-	TimerBar& timer_bar = row.mBars[bar_index];
+	const TimerBar& timer_bar = row.mBars[bar_index];
 	LLTrace::BlockTimerStatHandle* time_block = timer_bar.mTimeBlock;
 
 	hovered |= mHoverID == time_block;
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 74d7935727..d8ace6e014 100644
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -121,7 +121,7 @@ private:
 
 	F32Seconds updateTimerBarWidths(LLTrace::BlockTimerStatHandle* time_block, TimerBarRow& row, S32 history_index, U32& bar_index);
 	S32 updateTimerBarOffsets(LLTrace::BlockTimerStatHandle* time_block, TimerBarRow& row, S32 timer_bar_index = 0);
-	S32 drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered = false, bool visible = true, S32 bar_index = 0);
+	S32 drawBar(const LLRect& bar_rect, const TimerBarRow& row, S32 image_width, S32 image_height, bool hovered = false, bool visible = true, S32 bar_index = 0);
 	void setPauseState(bool pause_state);
 
 	std::deque<TimerBarRow> mTimerBarRows;
diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp
index a35bf3a9f1..4c0bf246a0 100644
--- a/indra/newview/llfavoritesbar.cpp
+++ b/indra/newview/llfavoritesbar.cpp
@@ -1012,7 +1012,7 @@ void LLFavoritesBarCtrl::updateMenuItems(LLToggleableMenu* menu)
 void LLFavoritesBarCtrl::fitLabelWidth(LLMenuItemCallGL* menu_item)
 {
 	U32 max_width = llmin(DROP_DOWN_MENU_WIDTH, getRect().getWidth());
-	std::string item_name = menu_item->getName();
+	const std::string& item_name = menu_item->getName();
 
 	// Check whether item name wider than menu
 	if (menu_item->getNominalWidth() > max_width)
diff --git a/indra/newview/llfloaterautoreplacesettings.cpp b/indra/newview/llfloaterautoreplacesettings.cpp
index a02d1ad975..2a7a57f5f2 100644
--- a/indra/newview/llfloaterautoreplacesettings.cpp
+++ b/indra/newview/llfloaterautoreplacesettings.cpp
@@ -244,7 +244,7 @@ void LLFloaterAutoReplaceSettings::updateReplacementsList()
 		const LLSD* mappings = mSettings.getListEntries(mSelectedListName);
 		for ( LLSD::map_const_iterator entry = mappings->beginMap(), end = mappings->endMap();
 			  entry != end;
-			  entry++
+			  ++entry
 			 )
 		{
 			LLSD row;
@@ -641,7 +641,7 @@ bool LLFloaterAutoReplaceSettings::selectedListIsLast()
 		LLSD lists = mSettings.getListNames(); // an Array of Strings
 		for ( LLSD::array_const_iterator list = lists.beginArray(), listEnd = lists.endArray();
 			  list != listEnd;
-			  list++
+			  ++list
 			 )
 		{
 			last = *list;
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index b4a57387b5..62be0069a5 100644
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -202,7 +202,7 @@ LLViewerFetchedTexture* bindMaterialDiffuseTexture(const LLImportMaterial& mater
 	return nullptr;
 }
 
-std::string stripSuffix(std::string name)
+std::string stripSuffix(const std::string& name)
 {
 	if ((name.find("_LOD") != std::string::npos) || (name.find("_PHYS") != std::string::npos))
 	{
@@ -4569,7 +4569,7 @@ void LLFloaterModelPreview::DecompRequest::completed()
 	}
 }
 
-void dump_llsd_to_file(const LLSD& content, std::string filename);
+void dump_llsd_to_file(const LLSD& content, const std::string& filename);
 
 void LLFloaterModelPreview::onPermissionsReceived(const LLSD& result)
 {
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index f85e0eaf65..7fc1c65e3d 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -769,7 +769,6 @@ skin_t manifestFromJson(const std::string& filename, const ESkinType type)
 {
 	skin_t skin;
 	nlohmann::json root;
-	std::string errors;
 	llifstream in;
 	in.open(filename);
 	if (in.is_open())
diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h
index a016a49200..bb84c74d1f 100644
--- a/indra/newview/llgroupmgr.h
+++ b/indra/newview/llgroupmgr.h
@@ -153,7 +153,7 @@ public:
 	S32 getTotalMembersInRole() const { return mMemberCount ? mMemberCount : mMemberIDs.size(); } //FIXME: Returns 0 for Everyone role when Member list isn't yet loaded, see MAINT-5225
 
 	LLRoleData getRoleData() const { return mRoleData; }
-	void setRoleData(LLRoleData data) { mRoleData = data; }
+	void setRoleData(const LLRoleData& data) { mRoleData = data; }
 	
 	void addMember(const LLUUID& member);
 	bool removeMember(const LLUUID& member);
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index fb97a83dc3..bce24f67c5 100644
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -408,12 +408,12 @@ namespace {
 }
 
 static S32 dump_num = 0;
-std::string make_dump_name(std::string prefix, S32 num)
+std::string make_dump_name(const std::string& prefix, S32 num)
 {
 	return prefix + fmt::to_string(num) + LLStringExplicit(".xml");
 }
-void dump_llsd_to_file(const LLSD& content, std::string filename);
-LLSD llsd_from_file(std::string filename);
+void dump_llsd_to_file(const LLSD& content, const std::string& filename);
+LLSD llsd_from_file(const std::string& filename);
 
 const std::string header_lod[] = 
 {
@@ -2158,7 +2158,7 @@ void LLMeshUploadThread::run()
 	}
 }
 
-void dump_llsd_to_file(const LLSD& content, std::string filename)
+void dump_llsd_to_file(const LLSD& content, const std::string& filename)
 {
 	if (gSavedSettings.getBOOL("MeshUploadLogXML"))
 	{
@@ -2167,9 +2167,9 @@ void dump_llsd_to_file(const LLSD& content, std::string filename)
 	}
 }
 
-LLSD llsd_from_file(std::string filename)
+LLSD llsd_from_file(const std::string& filename)
 {
-	llifstream ifs(filename.c_str());
+	llifstream ifs(filename);
 	LLSD result;
 	LLSDSerialize::fromXML(result,ifs);
 	return result;
@@ -3821,18 +3821,19 @@ void LLMeshRepository::notifyLoadedMeshes()
 		}
 		hold_offs = 0;
 		
-		if (gAgent.getRegion())
+		LLViewerRegion* regionp = gAgent.getRegion();
+		if (regionp)
 		{
 			// Update capability urls
 			static std::string region_name("never name a region this");
 			
-			if (gAgent.getRegion()->getName() != region_name && gAgent.getRegion()->capabilitiesReceived())
+			if (regionp->getName() != region_name && regionp->capabilitiesReceived())
 			{
-				region_name = gAgent.getRegion()->getName();
+				region_name = regionp->getName();
 				const bool use_v1(gSavedSettings.getBOOL("MeshUseGetMesh1"));
-				const std::string mesh_cap(gAgent.getRegion()->getViewerAssetUrl());
-				const std::string legacy_mesh1_cap(gAgent.getRegion()->getCapability("GetMesh"));
-				const std::string legacy_mesh2_cap(gAgent.getRegion()->getCapability("GetMesh2"));
+				const std::string mesh_cap(regionp->getViewerAssetUrl());
+				const std::string legacy_mesh1_cap(regionp->getCapability("GetMesh"));
+				const std::string legacy_mesh2_cap(regionp->getCapability("GetMesh2"));
 				mLegacyGetMeshVersion = ((mesh_cap.empty() && legacy_mesh2_cap.empty()) || use_v1) ? 1 : (!mesh_cap.empty() ? 0 : 2);
 				mThread->setGetMeshCap(mesh_cap, legacy_mesh1_cap, legacy_mesh2_cap, mLegacyGetMeshVersion);
 				LL_DEBUGS(LOG_MESH) << "Retrieving caps for region '" << region_name
diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h
index d689c7bb26..8e9f37afc1 100644
--- a/indra/newview/llmeshrepository.h
+++ b/indra/newview/llmeshrepository.h
@@ -93,6 +93,7 @@ public:
 	LLSD mPostData;
 
 	LLTextureUploadData()
+		: mTexture(nullptr)
 	{
 		mRetries = 0;
 	}
diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h
index a4ab621bc9..71f061ce88 100644
--- a/indra/newview/lloutfitgallery.h
+++ b/indra/newview/lloutfitgallery.h
@@ -267,7 +267,7 @@ public:
     void setOutfitName(std::string name);
     void setOutfitWorn(bool value);
     void setSelected(bool value);
-    void setUUID(LLUUID outfit_id) {mUUID = outfit_id;}
+    void setUUID(const LLUUID& outfit_id) {mUUID = outfit_id;}
     
     std::string getItemName() {return mOutfitName;}
     bool isDefaultImage() {return mDefaultImage;}
diff --git a/indra/newview/llsecapicerthandler.h b/indra/newview/llsecapicerthandler.h
index c14b13c438..04a2f4690b 100644
--- a/indra/newview/llsecapicerthandler.h
+++ b/indra/newview/llsecapicerthandler.h
@@ -484,9 +484,8 @@ class LLCertValidationExpirationException : public LLCertException
 public:
     LLCertValidationExpirationException(const LLSD& cert_data, const LLDate& current_time) 
     : LLCertException(cert_data, "CertExpired")
-    {
-        mTime = current_time;
-    }
+    , mTime(current_time)
+    { }
     virtual ~LLCertValidationExpirationException() noexcept = default;
     LLDate GetTime() const { return mTime; }
 protected:
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 976e746f87..8552a1896d 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -896,7 +896,7 @@ template <typename T> bool LLObjectSelection::getSelectedTEValue(LLSelectedTEGet
 
 	// Now iterate through all TEs to test for sameness
 	bool identical = TRUE;
-	for (iterator iter = begin(); iter != end(); iter++)
+	for (iterator iter = begin(); iter != end(); ++iter)
 	{
 		LLSelectNode* node = *iter;
 		LLViewerObject* object = node->getObject();
@@ -967,7 +967,7 @@ template <typename T> bool LLObjectSelection::isMultipleTEValue(LLSelectedTEGetF
 	
 	// Now iterate through all TEs to test for sameness
 	bool unique = TRUE;
-	for (iterator iter = begin(); iter != end(); iter++)
+	for (iterator iter = begin(); iter != end(); ++iter)
 	{
 		LLSelectNode* node = *iter;
 		LLViewerObject* object = node->getObject();
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index 8cd5ae557a..2a5c86b4c8 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -234,7 +234,7 @@ public:
 
 	struct CompareUpdateUrgency
 	{
-		bool operator()(const LLPointer<LLSpatialGroup> lhs, const LLPointer<LLSpatialGroup> rhs)
+		bool operator()(const LLPointer<LLSpatialGroup>& lhs, const LLPointer<LLSpatialGroup>& rhs)
 		{
 			return lhs->getUpdateUrgency() > rhs->getUpdateUrgency();
 		}
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index ca84e3da55..d379dbc684 100644
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -332,7 +332,7 @@ public:
 	BOOL needsAux() const { return mNeedsAux; }
 
 	// Host we think might have this image, used for baked av textures.
-	void setTargetHost(LLHost host)			{ mTargetHost = host; }
+	void setTargetHost(const LLHost& host)			{ mTargetHost = host; }
 	LLHost getTargetHost() const			{ return mTargetHost; }
 	
 	// Set the decode priority for this image...
diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h
index 648221130e..f9278ac3bf 100644
--- a/indra/newview/llviewertexturelist.h
+++ b/indra/newview/llviewertexturelist.h
@@ -206,7 +206,7 @@ private:
 	
 	// Request image from a specific host, used for baked avatar textures.
 	// Implemented in header in case someone changes default params above. JC
-	LLViewerFetchedTexture* getImageFromHost(const LLUUID& image_id, FTType f_type, LLHost host)
+	LLViewerFetchedTexture* getImageFromHost(const LLUUID& image_id, FTType f_type, const LLHost& host)
 	{ return getImage(image_id, f_type, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, host); }	
 
 public:
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index cdec2e00ec..e9c4ddcca5 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -5601,7 +5601,7 @@ void LLVOAvatar::resolveHeightAgent(const LLVector3 &in_pos_agent, LLVector3 &ou
 }
 
 
-void LLVOAvatar::resolveRayCollisionAgent(const LLVector3d start_pt, const LLVector3d end_pt, LLVector3d &out_pos, LLVector3 &out_norm)
+void LLVOAvatar::resolveRayCollisionAgent(const LLVector3d& start_pt, const LLVector3d& end_pt, LLVector3d &out_pos, LLVector3 &out_norm)
 {
 	LLViewerObject *obj;
 	LLWorld::getInstance()->resolveStepHeightGlobal(this, start_pt, end_pt, out_pos, out_norm, &obj);
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 481b192aad..f72cee4d39 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -915,7 +915,7 @@ public:
 	void 		resolveHeightGlobal(const LLVector3d &inPos, LLVector3d &outPos, LLVector3 &outNorm);
 	bool		distanceToGround( const LLVector3d &startPoint, LLVector3d &collisionPoint, F32 distToIntersectionAlongRay );
 	void 		resolveHeightAgent(const LLVector3 &inPos, LLVector3 &outPos, LLVector3 &outNorm);
-	void 		resolveRayCollisionAgent(const LLVector3d start_pt, const LLVector3d end_pt, LLVector3d &out_pos, LLVector3 &out_norm);
+	void 		resolveRayCollisionAgent(const LLVector3d& start_pt, const LLVector3d& end_pt, LLVector3d &out_pos, LLVector3 &out_norm);
 	void 		slamPosition(); // Slam position to transmitted position (for teleport);
 protected:
 
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index a2b1a06eb1..efc44346d2 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3125,7 +3125,7 @@ S32 LLVOVolume::getFaceIndexWithMediaImpl(const LLViewerMediaImpl* media_impl, S
 
 //----------------------------------------------------------------------------
 
-void LLVOVolume::setLightTextureID(LLUUID id)
+void LLVOVolume::setLightTextureID(const LLUUID& id)
 {
 	LLViewerTexture* old_texturep = getLightTexture(); // same as mLightTexture, but inits if nessesary
 	if (id.notNull())
@@ -3166,7 +3166,7 @@ void LLVOVolume::setLightTextureID(LLUUID id)
 	}		
 }
 
-void LLVOVolume::setSpotLightParams(LLVector3 params)
+void LLVOVolume::setSpotLightParams(const LLVector3& params)
 {
 	LLLightImageParams* param_block = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE);
 	if (param_block && param_block->getParams() != params)
diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h
index 00566ced07..b45be1823a 100644
--- a/indra/newview/llvovolume.h
+++ b/indra/newview/llvovolume.h
@@ -249,8 +249,8 @@ public:
 	void setLightRadius(F32 radius);
 	void setLightFalloff(F32 falloff);
 	void setLightCutoff(F32 cutoff);
-	void setLightTextureID(LLUUID id);
-	void setSpotLightParams(LLVector3 params);
+	void setLightTextureID(const LLUUID& id);
+	void setSpotLightParams(const LLVector3& params);
 
 	BOOL getIsLight() const;
 	LLColor3 getLightBaseColor() const; // not scaled by intensity
diff --git a/indra/newview/llwaterparamset.h b/indra/newview/llwaterparamset.h
index c8648d5f70..75729e68bc 100644
--- a/indra/newview/llwaterparamset.h
+++ b/indra/newview/llwaterparamset.h
@@ -132,8 +132,8 @@ public:
 inline void LLWaterParamSet::setAll(const LLSD& val)
 {
 	if(val.isMap()) {
-		LLSD::map_const_iterator mIt = val.beginMap();
-		for(; mIt != val.endMap(); mIt++)
+		
+		for(LLSD::map_const_iterator mIt = val.beginMap(), end_it = val.endMap(); mIt != end_it; ++mIt)
 		{
 			mParamValues[mIt->first] = mIt->second;
 		}
diff --git a/indra/newview/llworld.h b/indra/newview/llworld.h
index b606665b00..4f2ac27b47 100644
--- a/indra/newview/llworld.h
+++ b/indra/newview/llworld.h
@@ -59,9 +59,9 @@ class CapUrlMatches
 {
 public:
 	CapUrlMatches(std::set<LLViewerRegion*>& regions, std::set<std::string>& cap_names)
+		: mRegions(regions)
+		, mCapNames(cap_names)
 	{
-		mRegions = regions;
-		mCapNames = cap_names;
 	}
 
 	std::set<LLViewerRegion*> mRegions;
-- 
GitLab