This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix PR java/22189


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
--- /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()

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]