optimize SubchannelClassification.publish (manual getOrElse inline)

This commit is contained in:
Roland 2011-11-10 11:34:33 +01:00
parent 3e166030ec
commit 5b9a57d6e4

View file

@ -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, _))
}
}