On Tuesday 07 April 2009 16:26:42 j16sdiz at freenetproject.org wrote: > Author: j16sdiz > Date: 2009-04-07 15:26:41 +0000 (Tue, 07 Apr 2009) > New Revision: 26609 > > Modified: > trunk/freenet/src/freenet/crypt/Yarrow.java > Log: > Use int[] instead of Integer, save autoboxing and put() > > Modified: trunk/freenet/src/freenet/crypt/Yarrow.java > =================================================================== > --- trunk/freenet/src/freenet/crypt/Yarrow.java 2009-04-07 15:06:39 UTC > (rev 26608) > +++ trunk/freenet/src/freenet/crypt/Yarrow.java 2009-04-07 15:26:41 UTC > (rev 26609) > @@ -444,12 +444,12 @@ > private MessageDigest fast_pool, slow_pool; > private int fast_entropy, slow_entropy; > private boolean fast_select; > - private Map<EntropySource, Integer> entropySeen; > + private Map<EntropySource, int[]> entropySeen; > > private void accumulator_init(String digest) throws NoSuchAlgorithmException { > fast_pool = MessageDigest.getInstance(digest); > slow_pool = MessageDigest.getInstance(digest); > - entropySeen = new HashMap<EntropySource, Integer>(); > + entropySeen = new HashMap<EntropySource, int[]>(); > } > > @Override > @@ -515,21 +515,21 @@ > slow_entropy += actualEntropy; > > if(source != null) { > - Integer contributedEntropy = > entropySeen.get(source); > - if(contributedEntropy == null) > - contributedEntropy = > Integer.valueOf(actualEntropy); > - else > - contributedEntropy = > Integer.valueOf(actualEntropy + contributedEntropy.intValue()); > - entropySeen.put(source, > contributedEntropy); > + int[] contributedEntropy = > entropySeen.get(source); > + if(contributedEntropy == null) { > + contributedEntropy = new int[] > { actualEntropy }; > + entropySeen.put(source, > contributedEntropy); > + } else > + contributedEntropy[0]++;
Wrong. contributedEntropy[0] += actualEntropy; Please do not make mistakes in crypt/! Otherwise it's a neat optimisation, although using a MutableInt would be cleaner. > > if(slow_entropy >= (SLOW_THRESHOLD * > 2)) { > int kc = 0; > - for(Map.Entry<EntropySource, > Integer> e : entropySeen.entrySet()) { > + for(Map.Entry<EntropySource, > int[]> e : entropySeen.entrySet()) { > EntropySource key = > e.getKey(); > - Integer v = > e.getValue(); > + int[] v = e.getValue(); > if(DEBUG) > > Logger.normal(this, "Key: <" + key + "> " + v); > - if(v.intValue() > > SLOW_THRESHOLD) { > + if(v[0] > > SLOW_THRESHOLD) { > kc++; > if(kc >= > SLOW_K) { > > slow_pool_reseed(); -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 835 bytes Desc: This is a digitally signed message part. URL: <https://emu.freenetproject.org/pipermail/devl/attachments/20090407/5b0efece/attachment.pgp>