From d1cbb53a62fcfd8c150d4f006ab04c18711fc6d1 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Wed, 19 Feb 2020 04:13:34 -0500
Subject: [PATCH] Small friend check code cleanup

---
 indra/newview/llavataractions.cpp | 2 +-
 indra/newview/llcallingcard.cpp   | 2 +-
 indra/newview/llimprocessing.cpp  | 4 ++--
 indra/newview/llimview.cpp        | 4 ++--
 indra/newview/llpanelpeople.cpp   | 4 ++--
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp
index 87cdbe864e..324a240e5d 100644
--- a/indra/newview/llavataractions.cpp
+++ b/indra/newview/llavataractions.cpp
@@ -1276,7 +1276,7 @@ void LLAvatarActions::requestFriendship(const LLUUID& target_id, const std::stri
 //static
 bool LLAvatarActions::isFriend(const LLUUID& id)
 {
-	return (nullptr != LLAvatarTracker::instance().getBuddyInfo(id) );
+	return LLAvatarTracker::instance().isBuddy(id);
 }
 
 // static
diff --git a/indra/newview/llcallingcard.cpp b/indra/newview/llcallingcard.cpp
index 9685afb881..4844396391 100644
--- a/indra/newview/llcallingcard.cpp
+++ b/indra/newview/llcallingcard.cpp
@@ -473,7 +473,7 @@ void LLAvatarTracker::notifyObservers()
 		friend_observer->changed(mModifyMask);
 	}
 
-	for (auto buddy_id : mChangedBuddyIDs)
+	for (const auto& buddy_id : mChangedBuddyIDs)
 	{
 		notifyParticularFriendObservers(buddy_id);
 	}
diff --git a/indra/newview/llimprocessing.cpp b/indra/newview/llimprocessing.cpp
index 7150db280d..0570480325 100644
--- a/indra/newview/llimprocessing.cpp
+++ b/indra/newview/llimprocessing.cpp
@@ -509,7 +509,7 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,
         // object IMs contain sender object id in session_id (STORM-1209)
         || (dialog == IM_FROM_TASK && LLMuteList::getInstance()->isMuted(session_id));
 	bool is_owned_by_me = false;
-	bool is_friend = (LLAvatarTracker::instance().getBuddyInfo(from_id) == nullptr) ? false : true;
+	bool is_friend = LLAvatarTracker::instance().isBuddy(from_id);
 	bool accept_im_from_only_friend = gSavedSettings.getBOOL("VoiceCallsFriendsOnly");
 	bool is_linden = chat.mSourceType != CHAT_SOURCE_OBJECT &&
         LLMuteList::getInstance()->isLinden(name);
@@ -1389,7 +1389,7 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,
             {
                 return;
             }
-            else if (gSavedSettings.getBOOL("VoiceCallsFriendsOnly") && (LLAvatarTracker::instance().getBuddyInfo(from_id) == NULL))
+            else if (gSavedSettings.getBOOL("VoiceCallsFriendsOnly") && !LLAvatarTracker::instance().isBuddy(from_id))
             {
                 return;
             }
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 79c54d969e..14d1783c35 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -2695,7 +2695,7 @@ void LLIMMgr::addMessage(
 	if (gSavedSettings.getBOOL("VoiceCallsFriendsOnly") && !from_linden)
 	{
 		// Evaluate if we need to skip this message when that setting is true (default is false)
-		skip_message = (LLAvatarTracker::instance().getBuddyInfo(other_participant_id) == nullptr); // Skip non friends...
+		skip_message = !LLAvatarTracker::instance().isBuddy(other_participant_id); // Skip non friends...
 		skip_message &= !(other_participant_id == gAgentID); // You are your best friend... Don't skip yourself
 	}
 
@@ -3100,7 +3100,7 @@ void LLIMMgr::inviteToSession(
 	if (voice_invite)
 	{
 		bool isRejectGroupCall = (gSavedSettings.getBOOL("VoiceCallsRejectGroup") && (notify_box_type == "VoiceInviteGroup"));
-		bool isRejectNonFriendCall = (gSavedSettings.getBOOL("VoiceCallsFriendsOnly") && (LLAvatarTracker::instance().getBuddyInfo(caller_id) == nullptr));
+		bool isRejectNonFriendCall = (gSavedSettings.getBOOL("VoiceCallsFriendsOnly") && !LLAvatarTracker::instance().isBuddy(caller_id));
 		if (isRejectGroupCall || isRejectNonFriendCall || gAgent.isDoNotDisturb())
 		{
 			if (gAgent.isDoNotDisturb() && !isRejectGroupCall && !isRejectNonFriendCall)
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index b652866b55..0fa375400c 100644
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -918,14 +918,14 @@ void LLPanelPeople::updateButtons()
 		if (item_selected)
 		{
 			selected_id = selected_uuids.front();
-			is_friend = LLAvatarTracker::instance().getBuddyInfo(selected_id) != nullptr;
+			is_friend = LLAvatarTracker::instance().isBuddy(selected_id);
 			is_self = gAgent.getID() == selected_id;
 		}
 		else if (multiple_selected)
 		{
 			for (uuid_vec_t::const_iterator itr = selected_uuids.begin(); itr != selected_uuids.end(); ++itr)
 			{
-				if (LLAvatarTracker::instance().getBuddyInfo(*itr) != nullptr)
+				if (LLAvatarTracker::instance().isBuddy(*itr))
 				{
 					is_friend = true;
 				}
-- 
GitLab