Changeset 2758 in webkit for trunk/JavaScriptCore/kjs/lookup.cpp
- Timestamp:
- Nov 19, 2002, 10:59:28 AM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/lookup.cpp
r1024 r2758 31 31 using namespace KJS; 32 32 33 static bool keysMatch(const UChar *c, unsigned len, const char *s) 34 { 35 for (unsigned i = 0; i != len; i++, c++, s++) 36 if (c->unicode() != (unsigned char)*s) 37 return false; 38 return *s == 0; 39 } 40 33 41 const HashEntry* Lookup::findEntry( const struct HashTable *table, 34 42 const UChar *c, unsigned int len ) 35 43 { 44 #ifndef NDEBUG 36 45 if (table->type != 2) { 37 46 fprintf(stderr, "KJS: Unknown hash table version.\n"); 38 47 return 0; 39 48 } 40 char *ascii = new char[len+1]; 41 unsigned int i; 42 for(i = 0; i < len; i++, c++) { 43 if (!c->high()) 44 ascii[i] = c->low(); 45 else 46 break; 47 } 48 ascii[i] = '\0'; 49 #endif 49 50 50 int h = hash( ascii) % table->hashSize;51 int h = hash(c, len) % table->hashSize; 51 52 const HashEntry *e = &table->entries[h]; 52 53 53 54 // empty bucket ? 54 if (!e->s) { 55 delete [] ascii; 55 if (!e->s) 56 56 return 0; 57 }58 57 59 58 do { 60 59 // compare strings 61 if (strcmp(ascii, e->s) == 0) { 62 delete [] ascii; 60 if (keysMatch(c, len, e->s)) 63 61 return e; 64 }65 62 // try next bucket 66 63 e = e->next; 67 64 } while (e); 68 65 69 delete [] ascii;70 66 return 0; 71 67 }
Note:
See TracChangeset
for help on using the changeset viewer.