optimize SubchannelClassification.publish (manual getOrElse inline)
This commit is contained in:
parent
3e166030ec
commit
5b9a57d6e4
1 changed files with 5 additions and 4 deletions
|
|
@ -161,15 +161,16 @@ trait SubchannelClassification { this: EventBus ⇒
|
|||
|
||||
def publish(event: Event): Unit = {
|
||||
val c = classify(event)
|
||||
val recv = cache get c getOrElse {
|
||||
subscriptions.synchronized {
|
||||
cache get c getOrElse {
|
||||
val recv =
|
||||
if (cache contains c) cache(c) // c will never be removed from cache
|
||||
else subscriptions.synchronized {
|
||||
if (cache contains c) cache(c)
|
||||
else {
|
||||
val diff = subscriptions.addKey(c)
|
||||
cache = cache ++ diff
|
||||
cache(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
recv foreach (publish(event, _))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue