Changeset 2776 in webkit for trunk/JavaScriptCore/kjs/property_map.cpp
- Timestamp:
- Nov 20, 2002, 12:15:18 AM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/property_map.cpp
r2769 r2776 36 36 PropertyMap::~PropertyMap() 37 37 { 38 //printf("key count is %d\n", _keyCount);39 38 UString::Rep *key = _singleEntry.key; 40 39 if (key) … … 67 66 inline int PropertyMap::hash(const UString::Rep *s) const 68 67 { 69 return s->hash() & _tableSizeHashMask; 70 } 71 72 bool PropertyMap::keysMatch(const UString::Rep *a, const UString::Rep *b) 73 { 74 if (a == b) 75 return true; 76 77 int len = a->len; 78 if (len != b->len) 79 return false; 80 81 for (int i = 0; i != len; ++i) 82 if (a->dat[i].unicode() != b->dat[i].unicode()) 83 return false; 84 85 return true; 68 return s->hash() & _tableSizeMask; 86 69 } 87 70 … … 90 73 if (!_table) { 91 74 UString::Rep *key = _singleEntry.key; 92 if ( key && keysMatch(name._ustring.rep, key)) {75 if (name._ustring.rep == key) { 93 76 attributes = _singleEntry.attributes; 94 77 return _singleEntry.value; … … 99 82 int i = hash(name._ustring.rep); 100 83 while (UString::Rep *key = _table[i].key) { 101 if ( keysMatch(name._ustring.rep, key)) {84 if (name._ustring.rep == key) { 102 85 attributes = _table[i].attributes; 103 86 return _table[i].value; 104 87 } 105 i = (i + 1) & _tableSize HashMask;88 i = (i + 1) & _tableSizeMask; 106 89 } 107 90 return 0; … … 112 95 if (!_table) { 113 96 UString::Rep *key = _singleEntry.key; 114 if ( key && keysMatch(name._ustring.rep, key))97 if (name._ustring.rep == key) 115 98 return _singleEntry.value; 116 99 return 0; … … 119 102 int i = hash(name._ustring.rep); 120 103 while (UString::Rep *key = _table[i].key) { 121 if ( keysMatch(name._ustring.rep, key))104 if (name._ustring.rep == key) 122 105 return _table[i].value; 123 i = (i + 1) & _tableSize HashMask;106 i = (i + 1) & _tableSizeMask; 124 107 } 125 108 return 0; … … 131 114 UString::Rep *key = _singleEntry.key; 132 115 if (key) { 133 if ( keysMatch(name._ustring.rep, key)) {116 if (name._ustring.rep == key) { 134 117 _singleEntry.value = value; 135 118 return; … … 150 133 int i = hash(name._ustring.rep); 151 134 while (UString::Rep *key = _table[i].key) { 152 if ( keysMatch(name._ustring.rep, key)) {135 if (name._ustring.rep == key) { 153 136 // Put a new value in an existing hash table entry. 154 137 _table[i].value = value; … … 156 139 return; 157 140 } 158 i = (i + 1) & _tableSize HashMask;141 i = (i + 1) & _tableSizeMask; 159 142 } 160 143 … … 171 154 int i = hash(key); 172 155 while (_table[i].key) 173 i = (i + 1) & _tableSize HashMask;156 i = (i + 1) & _tableSizeMask; 174 157 175 158 _table[i].key = key; … … 184 167 185 168 _tableSize = oldTableSize ? oldTableSize * 2 : 16; 186 _tableSize HashMask = _tableSize - 1;169 _tableSizeMask = _tableSize - 1; 187 170 _table = (Entry *)calloc(_tableSize, sizeof(Entry)); 188 171 … … 208 191 if (!_table) { 209 192 key = _singleEntry.key; 210 if ( key && keysMatch(name._ustring.rep, key)) {193 if (name._ustring.rep == key) { 211 194 key->deref(); 212 195 _singleEntry.key = 0; … … 219 202 int i = hash(name._ustring.rep); 220 203 while ((key = _table[i].key)) { 221 if ( keysMatch(name._ustring.rep, key))204 if (name._ustring.rep == key) 222 205 break; 223 i = (i + 1) & _tableSize HashMask;206 i = (i + 1) & _tableSizeMask; 224 207 } 225 208 if (!key) … … 233 216 // Reinsert all the items to the right in the same cluster. 234 217 while (1) { 235 i = (i + 1) & _tableSize HashMask;218 i = (i + 1) & _tableSizeMask; 236 219 key = _table[i].key; 237 220 if (!key)
Note:
See TracChangeset
for help on using the changeset viewer.