| Index: src/objects.cc
|
| ===================================================================
|
| --- src/objects.cc (revision 3541)
|
| +++ src/objects.cc (working copy)
|
| @@ -6848,31 +6848,19 @@
|
| }
|
|
|
|
|
| -
|
| -// Find entry for key otherwise return -1.
|
| +// Find entry for key otherwise return kNotFound.
|
| template<typename Shape, typename Key>
|
| int HashTable<Shape, Key>::FindEntry(Key key) {
|
| - uint32_t nof = NumberOfElements();
|
| - if (nof == 0) return kNotFound; // Bail out if empty.
|
| -
|
| uint32_t capacity = Capacity();
|
| - uint32_t hash = Shape::Hash(key);
|
| - uint32_t entry = GetProbe(hash, 0, capacity);
|
| -
|
| - Object* element = KeyAt(entry);
|
| - uint32_t passed_elements = 0;
|
| - if (!element->IsNull()) {
|
| - if (!element->IsUndefined() && Shape::IsMatch(key, element)) return entry;
|
| - if (++passed_elements == nof) return kNotFound;
|
| + uint32_t entry = FirstProbe(Shape::Hash(key), capacity);
|
| + uint32_t count = 1;
|
| + // EnsureCapacity will guarantee the hash table is never full.
|
| + while (true) {
|
| + Object* element = KeyAt(entry);
|
| + if (element->IsUndefined()) break; // Empty entry.
|
| + if (!element->IsNull() && Shape::IsMatch(key, element)) return entry;
|
| + entry = NextProbe(entry, count++, capacity);
|
| }
|
| - for (uint32_t i = 1; !element->IsUndefined(); i++) {
|
| - entry = GetProbe(hash, i, capacity);
|
| - element = KeyAt(entry);
|
| - if (!element->IsNull()) {
|
| - if (!element->IsUndefined() && Shape::IsMatch(key, element)) return entry;
|
| - if (++passed_elements == nof) return kNotFound;
|
| - }
|
| - }
|
| return kNotFound;
|
| }
|
|
|
| @@ -6918,17 +6906,18 @@
|
| }
|
|
|
|
|
| +
|
| template<typename Shape, typename Key>
|
| uint32_t HashTable<Shape, Key>::FindInsertionEntry(uint32_t hash) {
|
| uint32_t capacity = Capacity();
|
| - uint32_t entry = GetProbe(hash, 0, capacity);
|
| - Object* element = KeyAt(entry);
|
| -
|
| - for (uint32_t i = 1; !(element->IsUndefined() || element->IsNull()); i++) {
|
| - entry = GetProbe(hash, i, capacity);
|
| - element = KeyAt(entry);
|
| + uint32_t entry = FirstProbe(hash, capacity);
|
| + uint32_t count = 1;
|
| + // EnsureCapacity will guarantee the hash table is never full.
|
| + while (true) {
|
| + Object* element = KeyAt(entry);
|
| + if (element->IsUndefined() || element->IsNull()) break;
|
| + entry = NextProbe(entry, count++, capacity);
|
| }
|
| -
|
| return entry;
|
| }
|
|
|
| @@ -7007,6 +6996,10 @@
|
| template
|
| int Dictionary<StringDictionaryShape, String*>::NumberOfEnumElements();
|
|
|
| +template
|
| +int HashTable<NumberDictionaryShape, uint32_t>::FindEntry(uint32_t);
|
| +
|
| +
|
| // Collates undefined and unexisting elements below limit from position
|
| // zero of the elements. The object stays in Dictionary mode.
|
| Object* JSObject::PrepareSlowElementsForSort(uint32_t limit) {
|
|
|