Author: toad
Date: 2008-04-22 22:49:12 +0000 (Tue, 22 Apr 2008)
New Revision: 19508

Modified:
   trunk/freenet/src/freenet/node/Node.java
Log:
Refactor slightly (optimise)

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2008-04-22 22:47:35 UTC (rev 
19507)
+++ trunk/freenet/src/freenet/node/Node.java    2008-04-22 22:49:12 UTC (rev 
19508)
@@ -2373,16 +2373,17 @@
                HashSet set = getUIDTracker(ssk, insert, offerReply, local);
                synchronized(set) {
                        if(logMINOR) Logger.minor(this, "Locking "+uid+" 
ssk="+ssk+" insert="+insert+" offerReply="+offerReply+" local="+local+" 
size="+set.size());
-                       if(set.contains(l))
+                       if(!set.add(l)) {
+                               // Already present.
                                return false;
-                       set.add(l);
+                       }
                        if(logMINOR) Logger.minor(this, "Locked "+uid+" 
ssk="+ssk+" insert="+insert+" offerReply="+offerReply+" local="+local+" 
size="+set.size());
                }
                synchronized(runningUIDs) {
-                       if(!runningUIDs.contains(l)) {
-                               runningUIDs.add(l);
+                       if(runningUIDs.add(l)) {
+                               // Not already present, we are okay.
                                return true;
-                       }
+                       } // Else is already present, we need to return false 
*and remove it from the other set*
                }
                synchronized(set) {
                        set.remove(l);


Reply via email to