r26606 - trunk/freenet/src/freenet/crypt

[email protected]
Newsgroups gmane.network.freenet.cvs
Message-ID <[email protected]>
Author: j16sdiz
Date: 2009-04-07 15:05:54 +0000 (Tue, 07 Apr 2009)
New Revision: 26606

Modified:
   trunk/freenet/src/freenet/crypt/Yarrow.java
Log:
Use HashMap instead of Hashtable

HashMap is around ~20% faster in java 1.5
(but no major different in 1.6)

Modified: trunk/freenet/src/freenet/crypt/Yarrow.java
===================================================================
--- trunk/freenet/src/freenet/crypt/Yarrow.java	2009-04-07 15:05:32 UTC (rev 26605)
+++ trunk/freenet/src/freenet/crypt/Yarrow.java	2009-04-07 15:05:54 UTC (rev 26606)
@@ -19,11 +19,12 @@
 import java.security.SecureRandom;
 import java.util.Arrays;
 import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Properties;
 
+import freenet.support.LogThresholdCallback;
 import freenet.support.Logger;
-import freenet.support.LogThresholdCallback;
 import freenet.support.io.Closer;
 
 /**
@@ -443,12 +444,12 @@
 	private MessageDigest fast_pool,  slow_pool;
 	private int fast_entropy,  slow_entropy;
 	private boolean fast_select;
-	private Hashtable<EntropySource, Integer> entropySeen;
+	private Map<EntropySource, Integer> entropySeen;
 
 	private void accumulator_init(String digest) throws NoSuchAlgorithmException {
 		fast_pool = MessageDigest.getInstance(digest);
 		slow_pool = MessageDigest.getInstance(digest);
-		entropySeen = new Hashtable<EntropySource, Integer>();
+		entropySeen = new HashMap<EntropySource, Integer>();
 	}
 
 	@Override
@@ -523,9 +524,9 @@
 
 					if(slow_entropy >= (SLOW_THRESHOLD * 2)) {
 						int kc = 0;
-						for(Enumeration<EntropySource> enu = entropySeen.keys(); enu.hasMoreElements();) {
-							Object key = enu.nextElement();
-							Integer v = entropySeen.get(key);
+						for(Map.Entry<EntropySource, Integer> e : entropySeen.entrySet()) {
+							EntropySource key = e.getKey();
+							Integer v = e.getValue();
 							if(DEBUG)
 								Logger.normal(this, "Key: <" + key + "> " + v);
 							if(v.intValue() > SLOW_THRESHOLD) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.