summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorAlexander Gavriliuk <alexandrgproductengine@lindenlab.com>2023-10-19 20:44:58 +0200
committerGuru <alexandrgproductengine@lindenlab.com>2023-10-20 01:45:57 +0200
commit537cb9117125f621f34b4d44e3f16a9c8c30313c (patch)
tree2b5ac264775dd71f96d3905f4d777e595fdd594f /indra/newview
parent735da0eb1d4bd24a1915a6cb2a9c2290a8e52bbe (diff)
SL-20163 Rework add/remove observers in LLAvatarPropertiesProcessor
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llavatarpropertiesprocessor.cpp48
1 files changed, 23 insertions, 25 deletions
diff --git a/indra/newview/llavatarpropertiesprocessor.cpp b/indra/newview/llavatarpropertiesprocessor.cpp
index 11609affcf..cc5fa949af 100644
--- a/indra/newview/llavatarpropertiesprocessor.cpp
+++ b/indra/newview/llavatarpropertiesprocessor.cpp
@@ -52,24 +52,23 @@ LLAvatarPropertiesProcessor::~LLAvatarPropertiesProcessor()
void LLAvatarPropertiesProcessor::addObserver(const LLUUID& avatar_id, LLAvatarPropertiesObserver* observer)
{
+ if (!observer)
+ return;
+
// Check if that observer is already in mObservers for that avatar_id
- observer_multimap_t::iterator it;
+ using pair = std::pair<LLUUID, LLAvatarPropertiesObserver*>;
+ observer_multimap_t::iterator begin = mObservers.begin();
+ observer_multimap_t::iterator end = mObservers.end();
+ observer_multimap_t::iterator it = std::find_if(begin, end, [&](const pair& p)
+ {
+ return p.first == avatar_id && p.second == observer;
+ });
// IAN BUG this should update the observer's UUID if this is a dupe - sent to PE
- it = mObservers.find(avatar_id);
- while (it != mObservers.end())
+ if (it == end)
{
- if (it->second == observer)
- {
- return;
- }
- else
- {
- ++it;
- }
+ mObservers.insert(pair(avatar_id, observer));
}
-
- mObservers.insert(std::pair<LLUUID, LLAvatarPropertiesObserver*>(avatar_id, observer));
}
void LLAvatarPropertiesProcessor::removeObserver(const LLUUID& avatar_id, LLAvatarPropertiesObserver* observer)
@@ -79,19 +78,18 @@ void LLAvatarPropertiesProcessor::removeObserver(const LLUUID& avatar_id, LLAvat
return;
}
- observer_multimap_t::iterator it;
- it = mObservers.find(avatar_id);
- while (it != mObservers.end())
- {
- if (it->second == observer)
- {
- mObservers.erase(it);
- break;
- }
- else
+ // Check if that observer is in mObservers for that avatar_id
+ using pair = std::pair<LLUUID, LLAvatarPropertiesObserver*>;
+ observer_multimap_t::iterator begin = mObservers.begin();
+ observer_multimap_t::iterator end = mObservers.end();
+ observer_multimap_t::iterator it = std::find_if(begin, end, [&](const pair& p)
{
- ++it;
- }
+ return p.first == avatar_id && p.second == observer;
+ });
+
+ if (it != end)
+ {
+ mObservers.erase(it);
}
}