From 12b90882e03229c6e67dcbb602a2e2698785b8f4 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Mon, 28 Sep 2020 18:53:49 -0400
Subject: [PATCH] Small cleanup and stringviewification

---
 indra/llcharacter/llcharacter.cpp | 14 +++++++++++---
 indra/llcharacter/llcharacter.h   |  2 +-
 indra/llui/llui.cpp               | 26 +++++++++++++++-----------
 3 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp
index bae969a8474..9faaddeef5c 100644
--- a/indra/llcharacter/llcharacter.cpp
+++ b/indra/llcharacter/llcharacter.cpp
@@ -265,15 +265,23 @@ void LLCharacter::dumpCharacter( LLJoint* joint )
 //-----------------------------------------------------------------------------
 void LLCharacter::setAnimationData(const std::string& name, void *data)
 {
-	mAnimationData[name] = data;
+	mAnimationData.insert_or_assign(name, data);
 }
 
 //-----------------------------------------------------------------------------
 // getAnimationData()
 //-----------------------------------------------------------------------------
-void* LLCharacter::getAnimationData(const std::string& name)
+void* LLCharacter::getAnimationData(const std::string_view name)
 {
-	return get_if_there(mAnimationData, name, (void*)NULL);
+	auto iter = mAnimationData.find(name);
+	if (iter == mAnimationData.end())
+	{
+		return nullptr;
+	}
+	else
+	{
+		return iter->second;
+	}
 }
 
 //-----------------------------------------------------------------------------
diff --git a/indra/llcharacter/llcharacter.h b/indra/llcharacter/llcharacter.h
index 680f1d93280..1fe9c906656 100644
--- a/indra/llcharacter/llcharacter.h
+++ b/indra/llcharacter/llcharacter.h
@@ -185,7 +185,7 @@ class LLCharacter
 
 	void setAnimationData(const std::string& name, void *data);
 	
-	void *getAnimationData(const std::string& name);
+	void *getAnimationData(const std::string_view name);
 
 	void removeAnimationData(const std::string& name);
 	
diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index 7e69e9ec8ac..019c5cbcd2a 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -89,23 +89,22 @@ static LLDefaultChildRegistry::Register<LLToolBar> register_toolbar("toolbar");
 // Functions
 //
 
-LLUUID find_ui_sound(const char * namep)
+LLUUID find_ui_sound(std::string_view name)
 {
-	std::string name = ll_safe_string(namep);
 	LLUUID uuid = LLUUID(NULL);
-	LLUI *ui_inst = LLUI::getInstance();
-	if (!ui_inst->mSettingGroups["config"]->controlExists(name))
+	LLUI& ui_inst = LLUI::instance();
+	if (!ui_inst.mSettingGroups["config"]->controlExists(name))
 	{
 		LL_WARNS() << "tried to make UI sound for unknown sound name: " << name << LL_ENDL;	
 	}
 	else
 	{
-		uuid = LLUUID(ui_inst->mSettingGroups["config"]->getString(name));
+		uuid = LLUUID(ui_inst.mSettingGroups["config"]->getString(name));
 		if (uuid.isNull())
 		{
-			if (ui_inst->mSettingGroups["config"]->getString(name) == LLUUID::null.asString())
+			if (ui_inst.mSettingGroups["config"]->getString(name) == LLUUID::null.asString())
 			{
-				if (ui_inst->mSettingGroups["config"]->getBOOL("UISndDebugSpamToggle"))
+				if (ui_inst.mSettingGroups["config"]->getBOOL("UISndDebugSpamToggle"))
 				{
 					LL_INFOS() << "UI sound name: " << name << " triggered but silent (null uuid)" << LL_ENDL;	
 				}				
@@ -115,9 +114,9 @@ LLUUID find_ui_sound(const char * namep)
 				LL_WARNS() << "UI sound named: " << name << " does not translate to a valid uuid" << LL_ENDL;	
 			}
 		}
-		else if (ui_inst->mAudioCallback != NULL)
+		else if (ui_inst.mAudioCallback != NULL)
 		{
-			if (ui_inst->mSettingGroups["config"]->getBOOL("UISndDebugSpamToggle"))
+			if (ui_inst.mSettingGroups["config"]->getBOOL("UISndDebugSpamToggle"))
 			{
 				LL_INFOS() << "UI sound name: " << name << LL_ENDL;	
 			}
@@ -127,9 +126,14 @@ LLUUID find_ui_sound(const char * namep)
 	return uuid;
 }
 
+LLUUID find_ui_sound(const char* namep)
+{
+	return find_ui_sound(absl::NullSafeStringView(namep));
+}
+
 void make_ui_sound(const char* namep)
 {
-	LLUUID soundUUID = find_ui_sound(namep);
+	LLUUID soundUUID = find_ui_sound(absl::NullSafeStringView(namep));
 	if(soundUUID.notNull())
 	{
 		LLUI::getInstance()->mAudioCallback(soundUUID);
@@ -138,7 +142,7 @@ void make_ui_sound(const char* namep)
 
 void make_ui_sound_deferred(const char* namep)
 {
-	LLUUID soundUUID = find_ui_sound(namep);
+	LLUUID soundUUID = find_ui_sound(absl::NullSafeStringView(namep));
 	if(soundUUID.notNull())
 	{
 		LLUI::getInstance()->mDeferredAudioCallback(soundUUID);
-- 
GitLab