[freenet-cvs] r11644 - trunk/freenet/src/freenet/crypt

toad at freenetproject.org toad at freenetproject.org
Tue Jan 30 15:22:23 UTC 2007


Author: toad
Date: 2007-01-30 15:22:22 +0000 (Tue, 30 Jan 2007)
New Revision: 11644

Modified:
   trunk/freenet/src/freenet/crypt/DSAGroup.java
Log:
Small memory/cpu optimisation

Modified: trunk/freenet/src/freenet/crypt/DSAGroup.java
===================================================================
--- trunk/freenet/src/freenet/crypt/DSAGroup.java	2007-01-28 17:56:32 UTC (rev 11643)
+++ trunk/freenet/src/freenet/crypt/DSAGroup.java	2007-01-30 15:22:22 UTC (rev 11644)
@@ -69,6 +69,8 @@
     }
 
     private void updateCachedHexStrings() {
+    	if(pAsHexString != null && qAsHexString != null && gAsHexString != null)
+    		return;
         pAsHexString = HexUtil.biToHex(p);
         qAsHexString = HexUtil.biToHex(q);
         gAsHexString = HexUtil.biToHex(g);
@@ -107,6 +109,7 @@
     //    }
 
     public String writeAsField() {
+    	updateCachedHexStrings();
         StringBuffer b = new StringBuffer();
         b.append(pAsHexString).append(',');
         b.append(qAsHexString).append(',');
@@ -144,14 +147,17 @@
     }
 
     public String getPAsHexString() {
+    	updateCachedHexStrings();
         return pAsHexString;
     }
 
     public String getQAsHexString() {
+    	updateCachedHexStrings();
         return qAsHexString;
     }
 
     public String getGAsHexString() {
+    	updateCachedHexStrings();
         return gAsHexString;
     }
 
@@ -347,6 +353,8 @@
 		BigInteger p = new NativeBigInteger(1, Base64.decode(fs.get("p")));
 		BigInteger q = new NativeBigInteger(1, Base64.decode(fs.get("q")));
 		BigInteger g = new NativeBigInteger(1, Base64.decode(fs.get("g")));
-		return new DSAGroup(p, q, g);
+		DSAGroup dg = new DSAGroup(p, q, g);
+		if(dg.equals(Global.DSAgroupBigA)) return Global.DSAgroupBigA;
+		return dg;
 	}
 }




More information about the cvs mailing list