mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-03 20:23:09 -06:00
Fixes
This commit is contained in:
parent
4463e42129
commit
03df3210f7
|
|
@ -262,10 +262,7 @@ func (n *Notifier) SharedUsers(userID string) []string {
|
||||||
func (n *Notifier) _sharedUsers(userID string) []string {
|
func (n *Notifier) _sharedUsers(userID string) []string {
|
||||||
n._sharedUserMap[userID] = struct{}{}
|
n._sharedUserMap[userID] = struct{}{}
|
||||||
for roomID, users := range n.roomIDToJoinedUsers {
|
for roomID, users := range n.roomIDToJoinedUsers {
|
||||||
users.Lock()
|
if ok := users.isIn(userID); !ok {
|
||||||
_, ok := users.set[userID]
|
|
||||||
users.Unlock()
|
|
||||||
if !ok {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, userID := range n._joinedUsers(roomID) {
|
for _, userID := range n._joinedUsers(roomID) {
|
||||||
|
|
@ -285,10 +282,8 @@ func (n *Notifier) IsSharedUser(userA, userB string) bool {
|
||||||
defer n.lock.RUnlock()
|
defer n.lock.RUnlock()
|
||||||
var okA, okB bool
|
var okA, okB bool
|
||||||
for _, users := range n.roomIDToJoinedUsers {
|
for _, users := range n.roomIDToJoinedUsers {
|
||||||
users.Lock()
|
okA = users.isIn(userA)
|
||||||
_, okA = users.set[userA]
|
okB = users.isIn(userB)
|
||||||
_, okB = users.set[userB]
|
|
||||||
users.Unlock()
|
|
||||||
if okA && okB {
|
if okA && okB {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
@ -562,9 +557,16 @@ func (s *userIDSet) precompute() {
|
||||||
s.precomputed = s.values()
|
s.precomputed = s.values()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *userIDSet) isIn(str string) bool {
|
||||||
|
s.Lock()
|
||||||
|
defer s.Unlock()
|
||||||
|
_, ok := s.set[str]
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
func (s *userIDSet) values() (vals []string) {
|
func (s *userIDSet) values() (vals []string) {
|
||||||
if len(s.precomputed) > 0 {
|
if len(s.precomputed) > 0 {
|
||||||
return s.precomputed
|
return s.precomputed // only return if not invalidated
|
||||||
}
|
}
|
||||||
vals = make([]string, 0, len(s.set))
|
vals = make([]string, 0, len(s.set))
|
||||||
for str := range s.set {
|
for str := range s.set {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue