Changeset 2800 in webkit for trunk/JavaScriptCore/kjs/property_map.cpp
- Timestamp:
- Nov 21, 2002, 7:39:47 AM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/property_map.cpp
r2794 r2800 26 26 #include "reference_list.h" 27 27 28 #define DO_CONSISTENCY_CHECK 0 29 28 30 // At the time I added this switch, the optimization still gave a 1.5% performance boost so I couldn't remove it. 29 31 #define USE_SINGLE_ENTRY 1 32 33 #if !DO_CONSISTENCY_CHECK 34 #define check() ((void)0) 35 #endif 30 36 31 37 namespace KJS { … … 132 138 void PropertyMap::put(const Identifier &name, ValueImp *value, int attributes) 133 139 { 140 check(); 141 134 142 UString::Rep *rep = name._ustring.rep; 135 143 … … 139 147 if (key) { 140 148 if (rep == key) { 141 149 _singleEntry.value = value; 142 150 return; 143 151 } … … 148 156 _singleEntry.attributes = attributes; 149 157 _keyCount = 1; 158 check(); 150 159 return; 151 160 } … … 173 182 _table[i].attributes = attributes; 174 183 ++_keyCount; 184 185 check(); 175 186 } 176 187 … … 188 199 void PropertyMap::expand() 189 200 { 201 check(); 202 190 203 int oldTableSize = _tableSize; 191 204 Entry *oldTable = _table; … … 210 223 211 224 free(oldTable); 225 226 check(); 212 227 } 213 228 214 229 void PropertyMap::remove(const Identifier &name) 215 230 { 231 check(); 232 216 233 UString::Rep *rep = name._ustring.rep; 217 234 … … 225 242 _singleEntry.key = 0; 226 243 _keyCount = 0; 244 check(); 227 245 } 228 246 #endif … … 254 272 insert(key, _table[i].value, _table[i].attributes); 255 273 } 274 275 check(); 256 276 } 257 277 … … 329 349 } 330 350 351 #if DO_CONSISTENCY_CHECK 352 353 void PropertyMap::check() 354 { 355 int count = 0; 356 for (int j = 0; j != _tableSize; ++j) { 357 UString::Rep *rep = _table[j].key; 358 if (!rep) 359 continue; 360 int i = hash(rep); 361 while (UString::Rep *key = _table[i].key) { 362 if (rep == key) 363 break; 364 i = (i + 1) & _tableSizeMask; 365 } 366 assert(i == j); 367 count++; 368 } 369 #if USE_SINGLE_ENTRY 370 if (_singleEntry.key) 371 count++; 372 #endif 373 assert(count == _keyCount); 374 if (_table) { 375 assert(_tableSize); 376 assert(_tableSizeMask); 377 assert(_tableSize == _tableSizeMask + 1); 378 } 379 } 380 381 #endif // DO_CONSISTENCY_CHECK 382 331 383 } // namespace KJS
Note:
See TracChangeset
for help on using the changeset viewer.