This is the mail archive of the java@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: compacting _Jv_Utf8Const


On Wednesday 05 May 2004 21:23, Per Bothner wrote:
> _Jv_Utf8Const names take up a fair amount of space.  (However, I don't
> have numbers on this.  Does anyone?)  Some of it is "overhead": the
> length (2 bytes), hash code (2 bytes), final '\0' (1 byte), and
> alignment (0-1 bytes).  How about this more compact encoding:
>
> struct _Jv_Utf8Const
> {
>    unsigned char hash;

With an 8-bit hashcode you will get so many collisions that you might as well 
not have one (so your hashtable degenerates into a list or tree).  Just try 
dong the calculation "if I have N strings, what is the probabilty that two 
have the same hashcode " for N = 2, 3, 4... and you'll see what I mean.

-- 
Chris Gray                                  /k/ Embedded Java Solutions
Embedded & Mobile Java, OSGi              http://www.kiffer.be/k/
chris.gray@kiffer.be                                      +32 3 216 0369


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