From 51dfc02aa229ee2dc8a040d14350c3f45a73f74d Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Thu, 9 Sep 2010 14:27:48 +0200 Subject: [PATCH] Added comments and removed inverted logic --- akka-actor/src/main/scala/actor/ActorRegistry.scala | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/akka-actor/src/main/scala/actor/ActorRegistry.scala b/akka-actor/src/main/scala/actor/ActorRegistry.scala index 1a52b1efc0..6c6056221a 100644 --- a/akka-actor/src/main/scala/actor/ActorRegistry.scala +++ b/akka-actor/src/main/scala/actor/ActorRegistry.scala @@ -164,10 +164,11 @@ class Index[K <: AnyRef,V <: AnyRef : Manifest] { //Returns whether it needs to be retried or not def tryPut(set: JSet[V], v: V): Boolean = { set.synchronized { - if (!set.isEmpty) { + if (set.isEmpty) true //IF the set is empty then it has been removed, so signal retry + else { //Else add the value to the set and signal that retry is not needed set add v false - } else true + } } } @@ -214,13 +215,13 @@ class Index[K <: AnyRef,V <: AnyRef : Manifest] { val set = container get key if (set ne null) { set.synchronized { - if (set.remove(value)) { - if (set.isEmpty) - container.remove(key,emptySet) + if (set.remove(value)) { //If we can remove the value + if (set.isEmpty) //and the set becomes empty + container.remove(key,emptySet) //We try to remove the key if it's mapped to an empty set } } } } - def clear = container.clear + def clear = { foreach(remove _) } } \ No newline at end of file