src/share/vm/libadt/dict.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Cdiff src/share/vm/libadt/dict.cpp

src/share/vm/libadt/dict.cpp

Print this page

        

*** 22,54 **** * */ #include "precompiled.hpp" #include "libadt/dict.hpp" - #include "memory/allocation.inline.hpp" - #include "memory/resourceArea.hpp" - #include "runtime/thread.hpp" // Dictionaries - An Abstract Data Type // %%%%% includes not needed with AVM framework - Ungar - // #include "port.hpp" - //IMPLEMENTATION - // #include "dict.hpp" - #include <assert.h> - // The iostream is not needed and it gets confused for gcc by the - // define of bool. - // - // #include <iostream.h> - //------------------------------data----------------------------------------- // String hash tables #define MAXID 20 ! static byte initflag = 0; // True after 1st initialization static const char shft[MAXID] = {1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6}; static short xsum[MAXID]; //------------------------------bucket--------------------------------------- class bucket : public ResourceObj { --- 22,42 ---- * */ #include "precompiled.hpp" #include "libadt/dict.hpp" // Dictionaries - An Abstract Data Type // %%%%% includes not needed with AVM framework - Ungar #include <assert.h> //------------------------------data----------------------------------------- // String hash tables #define MAXID 20 ! static uint8_t initflag = 0; // True after 1st initialization static const char shft[MAXID] = {1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6}; static short xsum[MAXID]; //------------------------------bucket--------------------------------------- class bucket : public ResourceObj {
*** 279,289 **** //------------------------------CmpDict-------------------------------------- // CmpDict compares two dictionaries; they must have the same keys (their // keys must match using CmpKey) and they must have the same values (pointer // comparison). If so 1 is returned, if not 0 is returned. ! int32 Dict::operator ==(const Dict &d2) const { if( _cnt != d2._cnt ) return 0; if( _hash != d2._hash ) return 0; if( _cmp != d2._cmp ) return 0; for( uint i=0; i < _size; i++) { // For complete hash table do bucket *b = &_bin[i]; // Handy shortcut --- 267,277 ---- //------------------------------CmpDict-------------------------------------- // CmpDict compares two dictionaries; they must have the same keys (their // keys must match using CmpKey) and they must have the same values (pointer // comparison). If so 1 is returned, if not 0 is returned. ! int32_t Dict::operator ==(const Dict &d2) const { if( _cnt != d2._cnt ) return 0; if( _hash != d2._hash ) return 0; if( _cmp != d2._cmp ) return 0; for( uint i=0; i < _size; i++) { // For complete hash table do bucket *b = &_bin[i]; // Handy shortcut
*** 316,326 **** // be in the range 0-127 (I double & add 1 to force oddness). Keys are // limited to MAXID characters in length. Experimental evidence on 150K of // C text shows excellent spreading of values for any size hash table. int hashstr(const void *t) { register char c, k = 0; ! register int32 sum = 0; register const char *s = (const char *)t; while( ((c = *s++) != '\0') && (k < MAXID-1) ) { // Get characters till null or MAXID-1 c = (c<<1)+1; // Characters are always odd! sum += c + (c<<shft[k++]); // Universal hash function --- 304,314 ---- // be in the range 0-127 (I double & add 1 to force oddness). Keys are // limited to MAXID characters in length. Experimental evidence on 150K of // C text shows excellent spreading of values for any size hash table. int hashstr(const void *t) { register char c, k = 0; ! register int32_t sum = 0; register const char *s = (const char *)t; while( ((c = *s++) != '\0') && (k < MAXID-1) ) { // Get characters till null or MAXID-1 c = (c<<1)+1; // Characters are always odd! sum += c + (c<<shft[k++]); // Universal hash function
*** 330,358 **** //------------------------------hashptr-------------------------------------- // Slimey cheap hash function; no guaranteed performance. Better than the // default for pointers, especially on MS-DOS machines. int hashptr(const void *key) { - #ifdef __TURBOC__ - return ((intptr_t)key >> 16); - #else // __TURBOC__ return ((intptr_t)key >> 2); - #endif } // Slimey cheap hash function; no guaranteed performance. int hashkey(const void *key) { return (intptr_t)key; } //------------------------------Key Comparator Functions--------------------- ! int32 cmpstr(const void *k1, const void *k2) { return strcmp((const char *)k1,(const char *)k2); } // Cheap key comparator. ! int32 cmpkey(const void *key1, const void *key2) { if (key1 == key2) return 0; intptr_t delta = (intptr_t)key1 - (intptr_t)key2; if (delta > 0) return 1; return -1; } --- 318,342 ---- //------------------------------hashptr-------------------------------------- // Slimey cheap hash function; no guaranteed performance. Better than the // default for pointers, especially on MS-DOS machines. int hashptr(const void *key) { return ((intptr_t)key >> 2); } // Slimey cheap hash function; no guaranteed performance. int hashkey(const void *key) { return (intptr_t)key; } //------------------------------Key Comparator Functions--------------------- ! int32_t cmpstr(const void *k1, const void *k2) { return strcmp((const char *)k1,(const char *)k2); } // Cheap key comparator. ! int32_t cmpkey(const void *key1, const void *key2) { if (key1 == key2) return 0; intptr_t delta = (intptr_t)key1 - (intptr_t)key2; if (delta > 0) return 1; return -1; }
src/share/vm/libadt/dict.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File