Optimization + less code

This commit is contained in:
Viktor Klang 2010-09-01 17:43:53 +02:00
parent e1ed8a6734
commit 7790fdbcdf

View file

@ -109,18 +109,15 @@ object ActorRegistry extends ListenerManagement {
* Finds all actors that has a specific id.
*/
def actorsFor(id: String): Array[ActorRef] = {
if (actorsById.containsKey(id)) {
actorsById.get(id).toArray(Naught)
} else Naught
val set = actorsById get id
if (set ne null) set toArray Naught
else Naught
}
/**
* Finds the actor that has a specific UUID.
*/
def actorFor(uuid: String): Option[ActorRef] = {
if (actorsByUUID.containsKey(uuid)) Some(actorsByUUID.get(uuid))
else None
}
def actorFor(uuid: String): Option[ActorRef] = Option(actorsByUUID get uuid)
/**
* Registers an actor in the ActorRegistry.