[freenet-cvs] r17499 - trunk/freenet/src/freenet/node

toad at freenetproject.org toad at freenetproject.org
Sun Feb 3 00:12:44 UTC 2008


Author: toad
Date: 2008-02-03 00:12:44 +0000 (Sun, 03 Feb 2008)
New Revision: 17499

Modified:
   trunk/freenet/src/freenet/node/FailureTableEntry.java
Log:
Same clarifications to other function

Modified: trunk/freenet/src/freenet/node/FailureTableEntry.java
===================================================================
--- trunk/freenet/src/freenet/node/FailureTableEntry.java	2008-02-03 00:11:02 UTC (rev 17498)
+++ trunk/freenet/src/freenet/node/FailureTableEntry.java	2008-02-03 00:12:44 UTC (rev 17499)
@@ -191,9 +191,11 @@
 
 	private synchronized void addRequestedFrom(PeerNode[] requestedFrom, long now) {
 		sentTime = now;
+		/** The number of new requestedFrom elements. These are moved to the beginning and the 
+		 * rest is nulled out. So this is also the index of the first non-null element in 
+		 * requestedFrom. */
 		int notIncluded = 0;
 		int nulls = 0;
-		int ptr = 0;
 		for(int i=0;i<requestedFrom.length;i++) {
 			PeerNode req = requestedFrom[i];
 			boolean requestorIncluded = false;
@@ -211,11 +213,10 @@
 				}
 			}
 			if(!requestorIncluded) {
-				notIncluded++;
-				requestedFrom[ptr++] = requestedFrom[i];
+				requestedFrom[notIncluded++] = requestedFrom[i];
 			} // if it's new, keep it in requestedFrom, otherwise delete it
 		}
-		for(int i=ptr;i<requestedFrom.length;i++) requestedFrom[i] = null;
+		for(int i=notIncluded;i<requestedFrom.length;i++) requestedFrom[i] = null;
 		if(notIncluded == 0 && nulls == 0) return;
 		// Because weak, these can become null; doesn't matter, but we want to minimise memory usage
 		if(notIncluded == nulls) {
@@ -227,7 +228,7 @@
 					requestedNodes[i] = pn.myRef;
 					requestedLocs[i] = pn.getLocation();
 					requestedTimes[i] = now;
-					if(x == ptr) break;
+					if(x == notIncluded) break;
 				}
 			}
 			return;
@@ -248,7 +249,7 @@
 			toIndex++;
 		}
 		
-		for(int fromIndex=0;fromIndex<ptr;fromIndex++) {
+		for(int fromIndex=0;fromIndex<notIncluded;fromIndex++) {
 			PeerNode pn = requestedFrom[fromIndex];
 			if(pn != null) {
 				newRequestedNodes[toIndex] = pn.myRef;




More information about the cvs mailing list