src/share/vm/libadt/dict.cpp

changeset 997
1580954e694c
parent 435
a61af66fc99e
child 1014
0fbdb4381b99
child 1040
98cb887364d3
equal deleted inserted replaced
996:5bfdb08ea692 997:1580954e694c
344 //------------------------------Key Comparator Functions--------------------- 344 //------------------------------Key Comparator Functions---------------------
345 int32 cmpstr(const void *k1, const void *k2) { 345 int32 cmpstr(const void *k1, const void *k2) {
346 return strcmp((const char *)k1,(const char *)k2); 346 return strcmp((const char *)k1,(const char *)k2);
347 } 347 }
348 348
349 // Slimey cheap key comparator. 349 // Cheap key comparator.
350 int32 cmpkey(const void *key1, const void *key2) { 350 int32 cmpkey(const void *key1, const void *key2) {
351 return (int32)((intptr_t)key1 - (intptr_t)key2); 351 if (key1 == key2) return 0;
352 intptr_t delta = (intptr_t)key1 - (intptr_t)key2;
353 if (delta > 0) return 1;
354 return -1;
352 } 355 }
353 356
354 //============================================================================= 357 //=============================================================================
355 //------------------------------reset------------------------------------------ 358 //------------------------------reset------------------------------------------
356 // Create an iterator and initialize the first variables. 359 // Create an iterator and initialize the first variables.

mercurial