[patch] Fix PR java/22189

Robin Green greenrd@greenrd.org
Mon Jun 27 12:00:00 GMT 2005


On Mon, Jun 27, 2005 at 10:40:15AM +0100, Andrew Haley wrote:
> Can you please submit the substantive change that fixes the bug as a
> separate patch?

OK, here it is. This should work because it corrects the rounding error
introduced by doing ((((capacity*3)/2)*2)/3) - see bug report.
I'll send the cleanup part of the patch in my next email.

-- 
Robin
-------------- next part --------------
--- /usr/src/debug/gcc-4.0.0-20050622/libjava/gnu/gcj/runtime/PersistentByteMap.java	2005-02-16 17:32:59.000000000 +0000
+++ gnu/gcj/runtime/PersistentByteMap.java	2005-06-27 12:38:18.000000000 +0100
@@ -175,10 +175,10 @@
       // We're going to make that size prime.  This isn't
       // strictly necessary but it can't hurt.
       //
-      // We expand the size by 3/2 because the hash table is
-      // intolerably slow when more than 2/3 full.
+      // We expand the size by 3/2 and round the result because
+      // the hash table is intolerably slow when more than 2/3 full.
       
-      BigInteger size = new BigInteger(Integer.toString(capacity * 3/2));
+      BigInteger size = new BigInteger(Integer.toString(((capacity*3)+1)/2));
       BigInteger two = BigInteger.ONE.add(BigInteger.ONE);
       
       if (size.getLowestSetBit() != 0) // A hard way to say isEven()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20050627/2647fdfd/attachment.sig>


More information about the Java-patches mailing list