Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(509)

Side by Side Diff: runtime/vm/hash_map.h

Issue 2300873002: VM: Compute static guarded cid for final instance fields. (Closed)
Patch Set: address comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/handles_impl.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_MAP_H_ 5 #ifndef VM_HASH_MAP_H_
6 #define VM_HASH_MAP_H_ 6 #define VM_HASH_MAP_H_
7 7
8 #include "vm/growable_array.h" // For Malloc, EmptyBase 8 #include "vm/growable_array.h" // For Malloc, EmptyBase
9 #include "vm/zone.h" 9 #include "vm/zone.h"
10 10
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 const typename KeyValueTrait::Value kNoValue = 161 const typename KeyValueTrait::Value kNoValue =
162 KeyValueTrait::ValueOf(typename KeyValueTrait::Pair()); 162 KeyValueTrait::ValueOf(typename KeyValueTrait::Pair());
163 typename KeyValueTrait::Pair* pair = Lookup(key); 163 typename KeyValueTrait::Pair* pair = Lookup(key);
164 return (pair == NULL) ? kNoValue : KeyValueTrait::ValueOf(*pair); 164 return (pair == NULL) ? kNoValue : KeyValueTrait::ValueOf(*pair);
165 } 165 }
166 166
167 167
168 template<typename KeyValueTrait, typename B, typename Allocator> 168 template<typename KeyValueTrait, typename B, typename Allocator>
169 typename KeyValueTrait::Pair* 169 typename KeyValueTrait::Pair*
170 BaseDirectChainedHashMap<KeyValueTrait, B, Allocator>::Iterator::Next() { 170 BaseDirectChainedHashMap<KeyValueTrait, B, Allocator>::Iterator::Next() {
171 const typename KeyValueTrait::Pair kNoPair = typename KeyValueTrait::Pair(); 171 const typename KeyValueTrait::Value kNoValue =
172 KeyValueTrait::ValueOf(typename KeyValueTrait::Pair());
172 173
173 if (array_index_ < map_.array_size_) { 174 if (array_index_ < map_.array_size_) {
174 // If we're not in the middle of a list, find the next array slot. 175 // If we're not in the middle of a list, find the next array slot.
175 if (list_index_ == kNil) { 176 if (list_index_ == kNil) {
176 while ((map_.array_[array_index_].kv == kNoPair) && 177 while (KeyValueTrait::ValueOf(map_.array_[array_index_].kv) == kNoValue &&
177 (array_index_ < map_.array_size_)) { 178 array_index_ < map_.array_size_) {
178 array_index_++; 179 array_index_++;
179 } 180 }
180 if (array_index_ < map_.array_size_) { 181 if (array_index_ < map_.array_size_) {
181 // When we're done with the list, we'll continue with the next array 182 // When we're done with the list, we'll continue with the next array
182 // slot. 183 // slot.
183 const intptr_t old_array_index = array_index_; 184 const intptr_t old_array_index = array_index_;
184 array_index_++; 185 array_index_++;
185 list_index_ = map_.array_[old_array_index].next; 186 list_index_ = map_.array_[old_array_index].next;
186 return &map_.array_[old_array_index].kv; 187 return &map_.array_[old_array_index].kv;
187 } else { 188 } else {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 360
360 static intptr_t KeyOf(Pair kv) { return kv.first(); } 361 static intptr_t KeyOf(Pair kv) { return kv.first(); }
361 static T ValueOf(Pair kv) { return kv; } 362 static T ValueOf(Pair kv) { return kv; }
362 static inline intptr_t Hashcode(Key key) { return key; } 363 static inline intptr_t Hashcode(Key key) { return key; }
363 static inline bool IsKeyEqual(Pair kv, Key key) { return kv.first() == key; } 364 static inline bool IsKeyEqual(Pair kv, Key key) { return kv.first() == key; }
364 }; 365 };
365 366
366 } // namespace dart 367 } // namespace dart
367 368
368 #endif // VM_HASH_MAP_H_ 369 #endif // VM_HASH_MAP_H_
OLDNEW
« no previous file with comments | « runtime/vm/handles_impl.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698