simplify control flow

This commit is contained in:
Alexander Zielenski 2022-08-29 11:52:35 -07:00
parent 7685b393c2
commit ee24648300
No known key found for this signature in database
GPG Key ID: 754BC11B447F7843

View File

@ -726,8 +726,15 @@ func (p *sharedProcessor) distribute(obj interface{}, sync bool) {
defer p.listenersLock.RUnlock()
for listener, isSyncing := range p.listeners {
if !sync || isSyncing {
switch {
case !sync:
// non-sync messages are delivered to every listener
listener.add(obj)
case isSyncing:
// sync messages are delivered to every syncing listenter
listener.add(obj)
default:
// skipping a sync obj for a non-syncing listener
}
}
}