Author: j16sdiz
Date: 2008-05-27 12:04:53 +0000 (Tue, 27 May 2008)
New Revision: 20101

Modified:
   branches/saltedhashstore/freenet/src/freenet/support/BloomFilter.java
Log:
BloomFilter: synchronize less


Modified: branches/saltedhashstore/freenet/src/freenet/support/BloomFilter.java
===================================================================
--- branches/saltedhashstore/freenet/src/freenet/support/BloomFilter.java       
2008-05-27 11:24:05 UTC (rev 20100)
+++ branches/saltedhashstore/freenet/src/freenet/support/BloomFilter.java       
2008-05-27 12:04:53 UTC (rev 20101)
@@ -59,19 +59,23 @@
                this.k = k;
        }

-       public synchronized void updateFilter(byte[] key) {
+       public void updateFilter(byte[] key) {
                int[] hashes = getHashes(key);
-               for (int i = 0; i < k; i++)
-                       setBit(hashes[i]);
+               synchronized (this) {
+                       for (int i = 0; i < k; i++)
+                               setBit(hashes[i]);
+               }
                force();
        }

-       public synchronized boolean checkFilter(byte[] key) {
+       public boolean checkFilter(byte[] key) {
                int[] hashes = getHashes(key);
-               for (int i = 0; i < k; i++)
-                       if (!getBit(hashes[i]))
-                               return false;
-               return true;
+               synchronized (this) {
+                       for (int i = 0; i < k; i++)
+                               if (!getBit(hashes[i]))
+                                       return false;
+                       return true;
+               }
        }

        private int[] getHashes(byte[] key) {


Reply via email to