Branch: Tag:

2012-06-12

2012-06-12 15:04:01 by Per Hedbor <ph@opera.com>

Use power-of-two hashtable for string->offset mapping for objects.

This could almost certainly be optimized further, but for now gives about
0.2% better performance in the benchmarks. Probably less in real code,
though.

93:      /* Define the size of the cache that is used for method lookup. */   /* A value of zero disables this cache */ - #define FIND_FUNCTION_HASHSIZE 15013 + #define FIND_FUNCTION_HASHSIZE 16384      /* Programs with less methods will not use the cache for method lookups.. */   #define FIND_FUNCTION_HASH_TRESHOLD 9
6436: Inside #if defined(FIND_FUNCTION_HASHSIZE)
   size_t hashval;    hashval = my_hash_string(name);    hashval += prog->id; -  hashval %= FIND_FUNCTION_HASHSIZE; +  hashval &= (FIND_FUNCTION_HASHSIZE-1);    if(is_same_string(cache[hashval].name,name) &&    cache[hashval].id==prog->id)    return cache[hashval].fun;