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: Clarifying PersistentByteMap (was: Re: [patch] Fix PR java/22189)


On Mon, Jun 27, 2005 at 01:52:19PM +0100, Andrew Haley wrote:
> This is also fine with a ChangeLog.

Attached.

Index: ChangeLog
from  Robin Green  <greenrd@greenrd.org>

	* gnu/gcj/runtime/PersistentByteMap.java: Rename capacity field to
	internal_capacity to clarify distinction between externally-visible
	capacity and internal capacity (real number of entries).
	* gnu/gcj/runtime/PersistentByteMap.java (init): Use internal_capacity
	instead of capacity local variable to clarify above distinction


--- gnu/gcj/runtime/PersistentByteMap.java~	2005-06-27 12:38:18.000000000 +0100
+++ gnu/gcj/runtime/PersistentByteMap.java	2005-06-27 12:49:35.000000000 +0100
@@ -67,7 +67,7 @@
 
   static private final int MAGIC = 0;
   static private final int VERSION = 4;
-  static private final int CAPACITY = 8;
+  static private final int INTERNAL_CAPACITY = 8;
   static private final int TABLE_BASE = 12;
   static private final int STRING_BASE = 16;
   static private final int STRING_SIZE = 20;
@@ -78,7 +78,7 @@
 
   static private final int TABLE_ENTRY_SIZE = 2 * INT_SIZE;
 
-  private int capacity;   // real number of entries
+  private int internal_capacity;   // number of entries
   private int table_base;   // offset from start of file, in bytes
   private int string_base;  // offset from start of file, in bytes
   private int string_size;  // size of string table, in bytes
@@ -155,7 +155,7 @@
       throw new IllegalArgumentException(f.getName());
 
     table_base = getWord (TABLE_BASE);
-    capacity = getWord (CAPACITY);
+    internal_capacity = getWord (INTERNAL_CAPACITY);
     string_base = getWord (STRING_BASE);
     string_size = getWord (STRING_SIZE);
     file_size = getWord (FILE_SIZE);
@@ -187,11 +187,11 @@
       while (! size.isProbablePrime(10))
 	size = size.add(two);
       
-      this.capacity = capacity = size.intValue();
+      this.internal_capacity = size.intValue();
     }
 
     table_base = 64;
-    string_base = table_base + capacity * TABLE_ENTRY_SIZE;
+    string_base = table_base + internal_capacity * TABLE_ENTRY_SIZE;
     string_size = 0;
     file_size = string_base;
     elements = 0;
@@ -207,12 +207,12 @@
     fc = raf.getChannel();
     buf = fc.map(FileChannel.MapMode.READ_WRITE, 0, raf.length());
 
-    for (int i = 0; i < capacity; i++)
+    for (int i = 0; i < internal_capacity; i++)
       putKeyPos(UNUSED_ENTRY, i);
         
     putWord(0x67636a64, MAGIC);
     putWord(0x01, VERSION);
-    putWord(capacity, CAPACITY);
+    putWord(internal_capacity, INTERNAL_CAPACITY);
     putWord(table_base, TABLE_BASE);
     putWord(string_base, STRING_BASE);
     putWord(file_size, FILE_SIZE);
@@ -305,7 +305,7 @@
          + ((b[1]&0xffL)<<8) 
          + ((b[2]&0xffL)<<16) 
          + ((b[3]&0xffL)<<24));
-    long result = hashIndex % (long)capacity;
+    long result = hashIndex % (long)internal_capacity;
     return (int)result;
   }
         
@@ -326,7 +326,7 @@
         // not be theoretically as good as open addressing, but it has
         // good cache behviour.
         hashIndex++;
-        hashIndex %= capacity;
+        hashIndex %= internal_capacity;
       }
     while (true);
   }
@@ -360,7 +360,7 @@
           }
                 
         hashIndex++;
-        hashIndex %= capacity;
+        hashIndex %= internal_capacity;
       }
     while (true);
   }
@@ -376,7 +376,7 @@
 	  {
 	    values = new HashMap();
 	
-	    for (int i = 0; i < capacity; i++)
+	    for (int i = 0; i < internal_capacity; i++)
 	      if (getKeyPos(i) != UNUSED_ENTRY)
 		{
 		  int pos = getValuePos(i);
@@ -437,7 +437,7 @@
   {
     // With the the table 2/3 full there will be on average 2 probes
     // for a successful search and 5 probes for an unsuccessful one.
-    return capacity * 2/3;
+    return internal_capacity * 2/3;
   }
 
   public void force()
@@ -463,7 +463,7 @@
     throws IllegalAccessException
   {
     // We can use a fast copy if the size of a map has not changed.
-    if (this.elements == 0 && t.capacity == this.capacity
+    if (this.elements == 0 && t.internal_capacity == this.internal_capacity
 	&& t.length == this.length)
       {
 	this.buf.position(0);
@@ -528,7 +528,7 @@
     public Object next()
     {
       count--;
-      for (int i = idx; i < capacity; i++)
+      for (int i = idx; i < internal_capacity; i++)
         if (getKeyPos(i) != UNUSED_ENTRY)
           {
             idx = i+1;

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]