mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-01 03:03:10 -06:00
Reduce allocations on presence
This commit is contained in:
parent
e5e3350ce1
commit
ca73cf09b3
|
|
@ -509,6 +509,7 @@ func (s userIDSet) remove(str string) {
|
|||
}
|
||||
|
||||
func (s userIDSet) values() (vals []string) {
|
||||
vals = make([]string, 0, len(s))
|
||||
for str := range s {
|
||||
vals = append(vals, str)
|
||||
}
|
||||
|
|
@ -529,6 +530,7 @@ func (s peekingDeviceSet) remove(d types.PeekingDevice) {
|
|||
}
|
||||
|
||||
func (s peekingDeviceSet) values() (vals []types.PeekingDevice) {
|
||||
vals = make([]types.PeekingDevice, 0, len(s))
|
||||
for d := range s {
|
||||
vals = append(vals, d)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,10 +68,9 @@ func (p *PresenceStreamProvider) IncrementalSync(
|
|||
// TODO: SharedUsers might get out of sync
|
||||
sharedUsers := p.notifier.SharedUsers(req.Device.UserID)
|
||||
|
||||
sharedUsersMap := map[string]bool{
|
||||
req.Device.UserID: true,
|
||||
}
|
||||
// convert array to a map for easier checking if a user exists
|
||||
sharedUsersMap := make(map[string]bool, len(sharedUsers))
|
||||
sharedUsersMap[req.Device.UserID] = true
|
||||
for i := range sharedUsers {
|
||||
sharedUsersMap[sharedUsers[i]] = true
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue