Author: j16sdiz
Date: 2009-04-08 00:54:33 +0000 (Wed, 08 Apr 2009)
New Revision: 26630

Modified:
   trunk/freenet/src/freenet/node/Location.java
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/node/PeerNode.java
Log:
Don't throw FSParseException, return -1.0

Exception is slower

Modified: trunk/freenet/src/freenet/node/Location.java
===================================================================
--- trunk/freenet/src/freenet/node/Location.java        2009-04-08 00:23:47 UTC 
(rev 26629)
+++ trunk/freenet/src/freenet/node/Location.java        2009-04-08 00:54:33 UTC 
(rev 26630)
@@ -13,14 +13,14 @@
  */
 public class Location {
 
-       public static double getLocation(String init) throws FSParseException {
+       public static double getLocation(String init) {
                try {
-                       if(init == null) throw new FSParseException("Null 
location");
+                       if(init == null) return -1;
                        double d = Double.parseDouble(init);
-                       if(d < 0.0 || d > 1.0) throw new 
FSParseException("Invalid location "+d);
+                       if(d < 0.0 || d > 1.0) return -1;
                        return d;
                } catch (NumberFormatException e) {
-                       throw new FSParseException(e);
+                       return -1;
                }
        }
        

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2009-04-08 00:23:47 UTC (rev 
26629)
+++ trunk/freenet/src/freenet/node/Node.java    2009-04-08 00:54:33 UTC (rev 
26630)
@@ -572,13 +572,10 @@
                
                swapIdentifier = 
Fields.bytesToLong(darknetCrypto.identityHashHash);
                String loc = fs.get("location");
-               try {
-                       lm.setLocation(Location.getLocation(loc));
-               } catch (FSParseException e) {
-                       IOException e1 = new IOException();
-                       e1.initCause(e);
-                       throw e1;
-               }
+                       double locD = Location.getLocation(loc);
+                       if (locD == -1.0)
+                               throw new IOException("Invalid location: " + 
loc);
+                       lm.setLocation(locD);
                myName = fs.get("myName");
                if(myName == null) {
                        myName = newName();

Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java        2009-04-08 00:23:47 UTC 
(rev 26629)
+++ trunk/freenet/src/freenet/node/PeerNode.java        2009-04-08 00:54:33 UTC 
(rev 26630)
@@ -402,7 +402,7 @@
                }
                String locationString = fs.get("location");
                String[] peerLocationsString = fs.getAll("peersLocation");
-               try {
+               
                        currentLocation = Location.getLocation(locationString);
                        if(peerLocationsString != null) {
                                double[] peerLocations = new 
double[peerLocationsString.length];
@@ -411,10 +411,6 @@
                                currentPeersLocation = peerLocations;
                        }
                        locSetTime = System.currentTimeMillis();
-               } catch(FSParseException e) {
-                       // Wait for them to send us an FNPLocChangeNotification
-                       currentLocation = -1.0;
-               }
 
                disableRouting = disableRoutingHasBeenSetLocally = false;
                disableRoutingHasBeenSetRemotely = false; // Assume so
@@ -2409,18 +2405,17 @@
 
                String locationString = fs.get("location");
                if(locationString != null) {
-                       try {
                                double newLoc = 
Location.getLocation(locationString);
+                               if (newLoc == -1) {
+                                       if(logMINOR)
+                                               Logger.minor(this, "Invalid or 
null location, waiting for FNPLocChangeNotification: locationString=" + 
locationString); 
+                               } else {
                                if(!Location.equals(newLoc, currentLocation)) {
                                        changedAnything = true;
                                        currentLocation = newLoc;
                                        locSetTime = System.currentTimeMillis();
                                }
-                       } catch(FSParseException e) {
-                               // Location is optional, we will wait for 
FNPLocChangeNotification. Until then we will use the last known location (or -1 
if we have never known).
-                               if(logMINOR)
-                                       Logger.minor(this, "Invalid or null 
location, waiting for FNPLocChangeNotification: " + e);
-                       }
+                               }
                }
                try {
                        String physical[] = fs.getAll("physical.udp");

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to