-
Notifications
You must be signed in to change notification settings - Fork 3
Conversation
subCfs := subscriber.filter.ContentFilters | ||
for _, cf := range subCfs { | ||
for i, cf := range subCfs { | ||
if cf.ContentTopic == contentFilter.ContentTopic { | ||
l := len(subCfs) - 1 | ||
subCfs[l], subCfs[i] = subCfs[i], subCfs[l] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems that this could just be subCfs[i] = subCfs[l]
given that we're dropping subCfs[l]
on the next line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. Simplified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚡️ Nice find and tests! Thank you for the quick fix.
if cf.ContentTopic == contentFilter.ContentTopic { | ||
l := len(subCfs) - 1 | ||
subCfs[l], subCfs[i] = subCfs[i], subCfs[l] | ||
subscriber.filter.ContentFilters = subCfs[:l] | ||
} | ||
} | ||
sub.subscribers[subIndex] = subscriber |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right, []Subscriber
instead of []*Subscriber
, it's messy when you don't use pointers. Alternative would be to set subscriber := &(sub.subscribers[subIndex])
up top, but this works too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me a while banging my head against the wall to notice that one...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good tests. 👍
Summary
Notes