Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Archive
Alchemy Viewer
Commits
176aa2aa
Commit
176aa2aa
authored
5 years ago
by
Rye Mutt
Browse files
Options
Downloads
Patches
Plain Diff
Speed up is buddy check with hashmap find
parent
53bfdd8f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
indra/newview/llcallingcard.cpp
+31
-37
31 additions, 37 deletions
indra/newview/llcallingcard.cpp
indra/newview/llcallingcard.h
+2
-0
2 additions, 0 deletions
indra/newview/llcallingcard.h
with
33 additions
and
37 deletions
indra/newview/llcallingcard.cpp
+
31
−
37
View file @
176aa2aa
...
@@ -225,11 +225,12 @@ S32 LLAvatarTracker::addBuddyList(const buddy_map_t& buds)
...
@@ -225,11 +225,12 @@ S32 LLAvatarTracker::addBuddyList(const buddy_map_t& buds)
for
(
buddy_map_t
::
const_iterator
itr
=
buds
.
begin
();
itr
!=
buds
.
end
();
++
itr
)
for
(
buddy_map_t
::
const_iterator
itr
=
buds
.
begin
();
itr
!=
buds
.
end
();
++
itr
)
{
{
agent_id
=
(
*
itr
).
first
;
agent_id
=
(
*
itr
).
first
;
buddy_map_t
::
const_iterator
existing_buddy
=
mBuddyInfo
.
find
(
agent_id
);
auto
existing_buddy
=
mBuddyInfo
.
find
(
agent_id
);
if
(
existing_buddy
==
mBuddyInfo
.
end
())
if
(
existing_buddy
==
mBuddyInfo
.
end
())
{
{
++
new_buddy_count
;
++
new_buddy_count
;
mBuddyInfo
[
agent_id
]
=
(
*
itr
).
second
;
auto
buddy
=
(
*
itr
).
second
;
auto
it
=
mBuddyInfo
.
emplace
(
agent_id
,
buddy
);
// pre-request name for notifications?
// pre-request name for notifications?
LLAvatarName
av_name
;
LLAvatarName
av_name
;
...
@@ -237,9 +238,9 @@ S32 LLAvatarTracker::addBuddyList(const buddy_map_t& buds)
...
@@ -237,9 +238,9 @@ S32 LLAvatarTracker::addBuddyList(const buddy_map_t& buds)
addChangedMask
(
LLFriendObserver
::
ADD
,
agent_id
);
addChangedMask
(
LLFriendObserver
::
ADD
,
agent_id
);
LL_DEBUGS
()
<<
"Added buddy "
<<
agent_id
LL_DEBUGS
()
<<
"Added buddy "
<<
agent_id
<<
", "
<<
(
mB
uddy
Info
[
agent_id
]
->
isOnline
()
?
"Online"
:
"Offline"
)
<<
", "
<<
(
b
uddy
->
isOnline
()
?
"Online"
:
"Offline"
)
<<
", TO: "
<<
mB
uddy
Info
[
agent_id
]
->
getRightsGrantedTo
()
<<
", TO: "
<<
b
uddy
->
getRightsGrantedTo
()
<<
", FROM: "
<<
mB
uddy
Info
[
agent_id
]
->
getRightsGrantedFrom
()
<<
", FROM: "
<<
b
uddy
->
getRightsGrantedFrom
()
<<
LL_ENDL
;
<<
LL_ENDL
;
}
}
else
else
...
@@ -261,12 +262,8 @@ S32 LLAvatarTracker::addBuddyList(const buddy_map_t& buds)
...
@@ -261,12 +262,8 @@ S32 LLAvatarTracker::addBuddyList(const buddy_map_t& buds)
void
LLAvatarTracker
::
copyBuddyList
(
buddy_map_t
&
buddies
)
const
void
LLAvatarTracker
::
copyBuddyList
(
buddy_map_t
&
buddies
)
const
{
{
buddy_map_t
::
const_iterator
it
=
mBuddyInfo
.
begin
();
if
(
!
mBuddyInfo
.
empty
())
buddy_map_t
::
const_iterator
end
=
mBuddyInfo
.
end
();
buddies
.
insert
(
mBuddyInfo
.
begin
(),
mBuddyInfo
.
end
());
for
(;
it
!=
end
;
++
it
)
{
buddies
[(
*
it
).
first
]
=
(
*
it
).
second
;
}
}
}
void
LLAvatarTracker
::
terminateBuddy
(
const
LLUUID
&
id
)
void
LLAvatarTracker
::
terminateBuddy
(
const
LLUUID
&
id
)
...
@@ -297,8 +294,7 @@ const LLRelationship* LLAvatarTracker::getBuddyInfo(const LLUUID& id) const
...
@@ -297,8 +294,7 @@ const LLRelationship* LLAvatarTracker::getBuddyInfo(const LLUUID& id) const
bool
LLAvatarTracker
::
isBuddy
(
const
LLUUID
&
id
)
const
bool
LLAvatarTracker
::
isBuddy
(
const
LLUUID
&
id
)
const
{
{
LLRelationship
*
info
=
get_ptr_in_map
(
mBuddyInfo
,
id
);
return
(
mBuddyInfo
.
find
(
id
)
!=
mBuddyInfo
.
end
());
return
(
info
!=
nullptr
);
}
}
// online status
// online status
...
@@ -538,11 +534,9 @@ void LLAvatarTracker::addChangedMask(U32 mask, const LLUUID& referent)
...
@@ -538,11 +534,9 @@ void LLAvatarTracker::addChangedMask(U32 mask, const LLUUID& referent)
void
LLAvatarTracker
::
applyFunctor
(
LLRelationshipFunctor
&
f
)
void
LLAvatarTracker
::
applyFunctor
(
LLRelationshipFunctor
&
f
)
{
{
buddy_map_t
::
iterator
it
=
mBuddyInfo
.
begin
();
for
(
auto
&
pair
:
mBuddyInfo
)
buddy_map_t
::
iterator
end
=
mBuddyInfo
.
end
();
for
(;
it
!=
end
;
++
it
)
{
{
f
(
(
*
it
)
.
first
,
(
*
it
)
.
second
);
f
(
pair
.
first
,
pair
.
second
);
}
}
}
}
...
@@ -611,16 +605,19 @@ void LLAvatarTracker::processChange(LLMessageSystem* msg)
...
@@ -611,16 +605,19 @@ void LLAvatarTracker::processChange(LLMessageSystem* msg)
msg
->
getS32Fast
(
_PREHASH_Rights
,
_PREHASH_RelatedRights
,
new_rights
,
i
);
msg
->
getS32Fast
(
_PREHASH_Rights
,
_PREHASH_RelatedRights
,
new_rights
,
i
);
if
(
agent_id
==
gAgent
.
getID
())
if
(
agent_id
==
gAgent
.
getID
())
{
{
if
(
mBuddyInfo
.
find
(
agent_related
)
!=
mBuddyInfo
.
end
())
auto
buddy_it
=
mBuddyInfo
.
find
(
agent_related
);
if
(
buddy_it
!=
mBuddyInfo
.
end
())
{
{
(
mBuddyInfo
[
agent_related
])
->
setRightsTo
(
new_rights
);
buddy_it
->
second
->
setRightsTo
(
new_rights
);
}
}
}
}
else
else
{
{
auto
buddy_it
=
mBuddyInfo
.
find
(
agent_id
);
if
(
mBuddyInfo
.
find
(
agent_id
)
!=
mBuddyInfo
.
end
())
if
(
mBuddyInfo
.
find
(
agent_id
)
!=
mBuddyInfo
.
end
())
{
{
S32
change
=
mB
uddy
Info
[
agent_id
]
->
getRightsGrantedFrom
()
^
new_rights
;
S32
change
=
b
uddy
_it
->
second
->
getRightsGrantedFrom
()
^
new_rights
;
if
(
change
)
if
(
change
)
{
{
LLSD
args
=
LLSD
().
with
(
"NAME"
,
LLSLURL
(
"agent"
,
agent_id
,
"displayname"
).
getSLURLString
());
LLSD
args
=
LLSD
().
with
(
"NAME"
,
LLSLURL
(
"agent"
,
agent_id
,
"displayname"
).
getSLURLString
());
...
@@ -636,7 +633,7 @@ void LLAvatarTracker::processChange(LLMessageSystem* msg)
...
@@ -636,7 +633,7 @@ void LLAvatarTracker::processChange(LLMessageSystem* msg)
?
"GrantedMapRights"
:
"RevokedMapRights"
,
args
,
payload
);
?
"GrantedMapRights"
:
"RevokedMapRights"
,
args
,
payload
);
}
}
}
}
(
mB
uddy
Info
[
agent_id
])
->
setRightsFrom
(
new_rights
);
b
uddy
_it
->
second
->
setRightsFrom
(
new_rights
);
}
}
}
}
}
}
...
@@ -739,13 +736,12 @@ void LLAvatarTracker::formFriendship(const LLUUID& id)
...
@@ -739,13 +736,12 @@ void LLAvatarTracker::formFriendship(const LLUUID& id)
{
{
if
(
id
.
notNull
())
if
(
id
.
notNull
())
{
{
LLRelationship
*
buddy_info
=
get_ptr_in_map
(
mBuddyInfo
,
id
);
if
(
mBuddyInfo
.
find
(
id
)
==
mBuddyInfo
.
end
())
if
(
!
buddy_info
)
{
{
//The default for relationship establishment is to have both parties
//The default for relationship establishment is to have both parties
//visible online to each other.
//visible online to each other.
buddy_info
=
new
LLRelationship
(
LLRelationship
::
GRANT_ONLINE_STATUS
,
LLRelationship
::
GRANT_ONLINE_STATUS
,
false
);
auto
buddy_info
=
new
LLRelationship
(
LLRelationship
::
GRANT_ONLINE_STATUS
,
LLRelationship
::
GRANT_ONLINE_STATUS
,
false
);
mBuddyInfo
[
id
]
=
buddy_info
;
mBuddyInfo
.
emplace
(
id
,
buddy_info
)
;
addChangedMask
(
LLFriendObserver
::
ADD
,
id
);
addChangedMask
(
LLFriendObserver
::
ADD
,
id
);
notifyObservers
();
notifyObservers
();
}
}
...
@@ -759,9 +755,10 @@ void LLAvatarTracker::processTerminateFriendship(LLMessageSystem* msg, void**)
...
@@ -759,9 +755,10 @@ void LLAvatarTracker::processTerminateFriendship(LLMessageSystem* msg, void**)
if
(
id
.
notNull
())
if
(
id
.
notNull
())
{
{
LLAvatarTracker
&
at
=
LLAvatarTracker
::
instance
();
LLAvatarTracker
&
at
=
LLAvatarTracker
::
instance
();
LLRelationship
*
buddy
=
get_ptr_in_map
(
at
.
mBuddyInfo
,
id
);
auto
it
=
at
.
mBuddyInfo
.
find
(
id
);
if
(
!
buddy
)
return
;
if
(
it
==
at
.
mBuddyInfo
.
end
())
return
;
at
.
mBuddyInfo
.
erase
(
id
);
auto
buddy
=
it
->
second
;
at
.
mBuddyInfo
.
erase
(
it
);
at
.
addChangedMask
(
LLFriendObserver
::
REMOVE
,
id
);
at
.
addChangedMask
(
LLFriendObserver
::
REMOVE
,
id
);
delete
buddy
;
delete
buddy
;
at
.
notifyObservers
();
at
.
notifyObservers
();
...
@@ -854,12 +851,11 @@ bool LLCollectProxyBuddies::operator()(const LLUUID& buddy_id, LLRelationship* b
...
@@ -854,12 +851,11 @@ bool LLCollectProxyBuddies::operator()(const LLUUID& buddy_id, LLRelationship* b
bool
LLCollectMappableBuddies
::
operator
()(
const
LLUUID
&
buddy_id
,
LLRelationship
*
buddy
)
bool
LLCollectMappableBuddies
::
operator
()(
const
LLUUID
&
buddy_id
,
LLRelationship
*
buddy
)
{
{
LLAvatarName
av_name
;
LLAvatarNameCache
::
get
(
buddy_id
,
&
av_name
);
buddy_map_t
::
value_type
value
(
buddy_id
,
av_name
.
getDisplayName
());
if
(
buddy
->
isOnline
()
&&
buddy
->
isRightGrantedFrom
(
LLRelationship
::
GRANT_MAP_LOCATION
))
if
(
buddy
->
isOnline
()
&&
buddy
->
isRightGrantedFrom
(
LLRelationship
::
GRANT_MAP_LOCATION
))
{
{
mMappable
.
insert
(
value
);
LLAvatarName
av_name
;
LLAvatarNameCache
::
get
(
buddy_id
,
&
av_name
);
mMappable
.
emplace
(
buddy_id
,
av_name
.
getDisplayName
());
}
}
return
true
;
return
true
;
}
}
...
@@ -869,10 +865,9 @@ bool LLCollectOnlineBuddies::operator()(const LLUUID& buddy_id, LLRelationship*
...
@@ -869,10 +865,9 @@ bool LLCollectOnlineBuddies::operator()(const LLUUID& buddy_id, LLRelationship*
LLAvatarName
av_name
;
LLAvatarName
av_name
;
LLAvatarNameCache
::
get
(
buddy_id
,
&
av_name
);
LLAvatarNameCache
::
get
(
buddy_id
,
&
av_name
);
mFullName
=
av_name
.
getUserName
();
mFullName
=
av_name
.
getUserName
();
buddy_map_t
::
value_type
value
(
buddy_id
,
mFullName
);
if
(
buddy
->
isOnline
())
if
(
buddy
->
isOnline
())
{
{
mOnline
.
insert
(
valu
e
);
mOnline
.
emplace
(
buddy_id
,
mFullNam
e
);
}
}
return
true
;
return
true
;
}
}
...
@@ -882,14 +877,13 @@ bool LLCollectAllBuddies::operator()(const LLUUID& buddy_id, LLRelationship* bud
...
@@ -882,14 +877,13 @@ bool LLCollectAllBuddies::operator()(const LLUUID& buddy_id, LLRelationship* bud
LLAvatarName
av_name
;
LLAvatarName
av_name
;
LLAvatarNameCache
::
get
(
buddy_id
,
&
av_name
);
LLAvatarNameCache
::
get
(
buddy_id
,
&
av_name
);
mFullName
=
av_name
.
getCompleteName
();
mFullName
=
av_name
.
getCompleteName
();
buddy_map_t
::
value_type
value
(
buddy_id
,
mFullName
);
if
(
buddy
->
isOnline
())
if
(
buddy
->
isOnline
())
{
{
mOnline
.
insert
(
valu
e
);
mOnline
.
emplace
(
buddy_id
,
mFullNam
e
);
}
}
else
else
{
{
mOffline
.
insert
(
valu
e
);
mOffline
.
emplace
(
buddy_id
,
mFullNam
e
);
}
}
return
true
;
return
true
;
}
}
This diff is collapsed.
Click to expand it.
indra/newview/llcallingcard.h
+
2
−
0
View file @
176aa2aa
...
@@ -32,6 +32,8 @@
...
@@ -32,6 +32,8 @@
#include
"lluuid.h"
#include
"lluuid.h"
#include
"v3dmath.h"
#include
"v3dmath.h"
#include
"absl/container/flat_hash_map.h"
class
LLMessageSystem
;
class
LLMessageSystem
;
class
LLTrackingData
;
class
LLTrackingData
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment