From a637f6c34eb961413c5e50bd8b17727ac1391d85 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Sun, 5 Jan 2020 03:59:38 -0500
Subject: [PATCH] Reduce string copies

---
 indra/llappearance/llavatarappearance.cpp | 2 +-
 indra/llappearance/llavatarappearance.h   | 2 +-
 indra/llcharacter/llcharacter.h           | 2 +-
 indra/llcommon/llinitparam.h              | 2 +-
 indra/llui/llbadge.h                      | 2 +-
 indra/llui/lllineeditor.h                 | 2 +-
 indra/llui/llmenugl.h                     | 2 +-
 indra/llui/llpanel.h                      | 4 ++--
 indra/llui/llview.h                       | 2 +-
 indra/newview/llagent.h                   | 2 +-
 indra/newview/llappearancemgr.cpp         | 2 +-
 11 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/indra/llappearance/llavatarappearance.cpp b/indra/llappearance/llavatarappearance.cpp
index e983e16f1c..195eda928a 100644
--- a/indra/llappearance/llavatarappearance.cpp
+++ b/indra/llappearance/llavatarappearance.cpp
@@ -1322,7 +1322,7 @@ LLJoint* LLAvatarAppearance::findCollisionVolume(S32 volume_id)
 //-----------------------------------------------------------------------------
 // findCollisionVolume()
 //-----------------------------------------------------------------------------
-S32 LLAvatarAppearance::getCollisionVolumeID(std::string &name)
+S32 LLAvatarAppearance::getCollisionVolumeID(const std::string &name)
 {
 	for (S32 i = 0; i < mNumCollisionVolumes; i++)
 	{
diff --git a/indra/llappearance/llavatarappearance.h b/indra/llappearance/llavatarappearance.h
index a10087b692..ec360db743 100644
--- a/indra/llappearance/llavatarappearance.h
+++ b/indra/llappearance/llavatarappearance.h
@@ -95,7 +95,7 @@ public:
 	/*virtual*/ const char*		getAnimationPrefix() override { return "avatar"; }
 	/*virtual*/ LLVector3		getVolumePos(S32 joint_index, LLVector3& volume_offset) override;
 	/*virtual*/ LLJoint*		findCollisionVolume(S32 volume_id) override;
-	/*virtual*/ S32				getCollisionVolumeID(std::string &name) override;
+	/*virtual*/ S32				getCollisionVolumeID(const std::string &name) override;
 	/*virtual*/ LLPolyMesh*		getHeadMesh() override;
 	/*virtual*/ LLPolyMesh*		getUpperBodyMesh() override;
 
diff --git a/indra/llcharacter/llcharacter.h b/indra/llcharacter/llcharacter.h
index 4b7970375a..da403f54e2 100644
--- a/indra/llcharacter/llcharacter.h
+++ b/indra/llcharacter/llcharacter.h
@@ -182,7 +182,7 @@ public:
 	
 	virtual LLJoint* findCollisionVolume(S32 volume_id) { return nullptr; }
 
-	virtual S32 getCollisionVolumeID(std::string &name) { return -1; }
+	virtual S32 getCollisionVolumeID(const std::string &name) { return -1; }
 
 	void setAnimationData(const std::string& name, void *data);
 	
diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h
index 7de54fc0ca..3c87ff059c 100644
--- a/indra/llcommon/llinitparam.h
+++ b/indra/llcommon/llinitparam.h
@@ -333,7 +333,7 @@ namespace LLInitParam
 				}
 			}
 
-			return "";
+			return std::string();
 		}
 
 		void clearValueName() const
diff --git a/indra/llui/llbadge.h b/indra/llui/llbadge.h
index db4e3880aa..a99c082d07 100644
--- a/indra/llui/llbadge.h
+++ b/indra/llui/llbadge.h
@@ -134,7 +134,7 @@ public:
 
 	void		draw() override;
 
-	const std::string	getLabel() const { return wstring_to_utf8str(mLabel); }
+	const std::string&	getLabel() const { return mLabel.getString(); }
 	void				setLabel( const LLStringExplicit& label);
 
 	void				setDrawAtParentTop(bool draw_at_top) { mDrawAtParentTop = draw_at_top;}
diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h
index 916937e483..e53a4b3952 100644
--- a/indra/llui/lllineeditor.h
+++ b/indra/llui/lllineeditor.h
@@ -199,7 +199,7 @@ public:
 	void			setText(const LLStringExplicit &new_text);
 
 	const std::string& getText() const		{ return mText.getString(); }
-	LLWString       getWText() const	{ return mText.getWString(); }
+	const LLWString&   getWText() const		{ return mText.getWString(); }
 	LLWString getConvertedText() const; // trimmed text with paragraphs converted to newlines
 
 	S32				getLength() const	{ return mText.length(); }
diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h
index 36332ca5b9..c0635801a3 100644
--- a/indra/llui/llmenugl.h
+++ b/indra/llui/llmenugl.h
@@ -114,7 +114,7 @@ public:
 
 	// change the label
 	void setLabel( const LLStringExplicit& label ) { mLabel = label; }	
-	std::string getLabel( void ) const { return mLabel.getString(); }
+	const std::string& getLabel( void ) const { return mLabel.getString(); }
 	BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ) override;
 
 	// Get the parent menu for this item
diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h
index 779e471652..4bcc558636 100644
--- a/indra/llui/llpanel.h
+++ b/indra/llui/llpanel.h
@@ -151,9 +151,9 @@ public:
 	void			setDefaultBtn(const std::string& id);
 	void			updateDefaultBtn();
 	void			setLabel(const LLStringExplicit& label) { mLabel = label; }
-	std::string		getLabel() const { return mLabel; }
+	const std::string&		getLabel() const { return mLabel.getString(); }
 	void			setHelpTopic(const std::string& help_topic) { mHelpTopic = help_topic; }
-	std::string		getHelpTopic() const { return mHelpTopic; }
+	const std::string&		getHelpTopic() const { return mHelpTopic; }
 	
 	void			setCtrlsEnabled(BOOL b);
 	ctrl_list_t		getCtrlList() const;
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index 948a898e41..f2742c4af7 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -319,7 +319,7 @@ public:
 	virtual LLRect getSnapRect() const;
 	LLRect getLocalSnapRect() const;
 
-	std::string getLayout() { return mLayout; }
+	const std::string& getLayout() { return mLayout; }
 
 	// Override and return required size for this object. 0 for width/height means don't care.
 	virtual LLRect getRequiredRect();
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index 0d45a82c48..549820ccc3 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -583,7 +583,7 @@ public:
 	BOOL			getAutoPilotUseRotation() const		{ return mAutoPilotUseRotation; }
 	LLVector3		getAutoPilotTargetFacing() const	{ return mAutoPilotTargetFacing; }
 	F32				getAutoPilotRotationThreshold() const	{ return mAutoPilotRotationThreshold; }
-	std::string		getAutoPilotBehaviorName() const	{ return mAutoPilotBehaviorName; }
+	const std::string&	getAutoPilotBehaviorName() const	{ return mAutoPilotBehaviorName; }
 
 	void			startAutoPilotGlobal(const LLVector3d &pos_global, 
 										 const std::string& behavior_name = std::string(), 
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 27dfdd9267..0644fdb251 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -2308,7 +2308,7 @@ void LLAppearanceMgr::createBaseOutfitLink(const LLUUID& category, LLPointer<LLI
 {
 	const LLUUID cof = getCOF();
 	LLViewerInventoryCategory* catp = gInventory.getCategory(category);
-	std::string new_outfit_name = "";
+	std::string new_outfit_name;
 
 	purgeBaseOutfitLink(cof, link_waiter);
 
-- 
GitLab