Skip to content

Commit

Permalink
[IMPROVED] The func subjectIsSubsetMatch() is heavy so do without the…
Browse files Browse the repository at this point in the history
… account lock. (#4586)

Signed-off-by: Derek Collison <derek@nats.io>
  • Loading branch information
derekcollison committed Sep 25, 2023
2 parents 62faa18 + fb4e97e commit 73f8f87
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions server/accounts.go
Expand Up @@ -1716,15 +1716,21 @@ func (a *Account) checkForReverseEntries(reply string, checkInterest, recursed b

var _rs [64]string
rs := _rs[:0]

if n := len(a.imports.rrMap); n > cap(rs) {
rs = make([]string, 0, n)
}

for k := range a.imports.rrMap {
if subjectIsSubsetMatch(k, reply) {
rs = append(rs, k)
}
rs = append(rs, k)
}
a.mu.RUnlock()

// subjectIsSubsetMatch is heavy so make sure we do this without the lock.
for _, r := range rs {
a._checkForReverseEntry(r, nil, checkInterest, recursed)
if subjectIsSubsetMatch(r, reply) {
a._checkForReverseEntry(r, nil, checkInterest, recursed)
}
}
}

Expand Down

0 comments on commit 73f8f87

Please sign in to comment.