Skip to content

Commit

Permalink
Optimize stream.partitionUnique()
Browse files Browse the repository at this point in the history
Make use of the consumers' tokenized filter subjects.

Signed-off-by: Sven Neumann <sven.neumann@holoplot.com>
  • Loading branch information
svenfoo committed Dec 8, 2023
1 parent 249bade commit fd6cc67
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -5291,6 +5291,8 @@ func (mset *stream) Store() StreamStore {
// Lock should be held.
func (mset *stream) partitionUnique(name string, partitions []string) bool {
for _, partition := range partitions {
psa := [32]string{}
pts := tokenizeSubjectIntoSlice(psa[:0], partition)
for n, o := range mset.consumers {
// Skip the consumer being checked.
if n == name {
Expand All @@ -5300,8 +5302,8 @@ func (mset *stream) partitionUnique(name string, partitions []string) bool {
return false
}
for _, filter := range o.subjf {
if subjectIsSubsetMatch(partition, filter.subject) ||
subjectIsSubsetMatch(filter.subject, partition) {
if isSubsetMatchTokenized(pts, filter.tokenizedSubject) ||
isSubsetMatchTokenized(filter.tokenizedSubject, pts) {
return false
}
}
Expand Down

0 comments on commit fd6cc67

Please sign in to comment.