Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_HASH_TABLE_H_ | 5 #ifndef VM_HASH_TABLE_H_ |
| 6 #define VM_HASH_TABLE_H_ | 6 #define VM_HASH_TABLE_H_ |
| 7 | 7 |
| 8 // Temporarily used when sorting the indices in EnumIndexHashTable. | 8 // Temporarily used when sorting the indices in EnumIndexHashTable. |
| 9 // TODO(koda): Remove these dependencies before using in production. | 9 // TODO(koda): Remove these dependencies before using in production. |
| 10 #include <map> | 10 #include <map> |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 629 | 629 |
| 630 // If 'key' is not present, insert and return it. Else, return the existing | 630 // If 'key' is not present, insert and return it. Else, return the existing |
| 631 // key in the set (useful for canonicalization). | 631 // key in the set (useful for canonicalization). |
| 632 RawObject* InsertOrGet(const Object& key) const { | 632 RawObject* InsertOrGet(const Object& key) const { |
| 633 EnsureCapacity(); | 633 EnsureCapacity(); |
| 634 intptr_t entry = -1; | 634 intptr_t entry = -1; |
| 635 if (!BaseIterTable::FindKeyOrDeletedOrUnused(key, &entry)) { | 635 if (!BaseIterTable::FindKeyOrDeletedOrUnused(key, &entry)) { |
| 636 BaseIterTable::InsertKey(entry, key); | 636 BaseIterTable::InsertKey(entry, key); |
| 637 return key.raw(); | 637 return key.raw(); |
| 638 } else { | 638 } else { |
| 639 return BaseIterTable::GetPayload(entry, 0); | 639 return BaseIterTable::GetKey(entry); |
|
Florian Schneider
2016/04/12 05:49:03
Oops. Good catch.
| |
| 640 } | 640 } |
| 641 } | 641 } |
| 642 | 642 |
| 643 // Like InsertOrGet, but calls NewKey to allocate a key object if needed. | 643 // Like InsertOrGet, but calls NewKey to allocate a key object if needed. |
| 644 template<typename Key> | 644 template<typename Key> |
| 645 RawObject* InsertNewOrGet(const Key& key) const { | 645 RawObject* InsertNewOrGet(const Key& key) const { |
| 646 EnsureCapacity(); | 646 EnsureCapacity(); |
| 647 intptr_t entry = -1; | 647 intptr_t entry = -1; |
| 648 if (!BaseIterTable::FindKeyOrDeletedOrUnused(key, &entry)) { | 648 if (!BaseIterTable::FindKeyOrDeletedOrUnused(key, &entry)) { |
| 649 BaseIterTable::KeyHandle() = | 649 BaseIterTable::KeyHandle() = |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 703 class EnumIndexHashSet : public HashSet<EnumIndexHashTable<KeyTraits, 0> > { | 703 class EnumIndexHashSet : public HashSet<EnumIndexHashTable<KeyTraits, 0> > { |
| 704 public: | 704 public: |
| 705 typedef HashSet<EnumIndexHashTable<KeyTraits, 0> > BaseSet; | 705 typedef HashSet<EnumIndexHashTable<KeyTraits, 0> > BaseSet; |
| 706 explicit EnumIndexHashSet(RawArray* data) : BaseSet(data) {} | 706 explicit EnumIndexHashSet(RawArray* data) : BaseSet(data) {} |
| 707 EnumIndexHashSet(Zone* zone, RawArray* data) : BaseSet(zone, data) {} | 707 EnumIndexHashSet(Zone* zone, RawArray* data) : BaseSet(zone, data) {} |
| 708 }; | 708 }; |
| 709 | 709 |
| 710 } // namespace dart | 710 } // namespace dart |
| 711 | 711 |
| 712 #endif // VM_HASH_TABLE_H_ | 712 #endif // VM_HASH_TABLE_H_ |
| OLD | NEW |