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

Side by Side Diff: runtime/vm/hash_table_test.cc

Issue 1873283003: Provide a mechanism for naming a hash table so that it can be used in DumpStats to identify the tab… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | 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) 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 #include <algorithm> 5 #include <algorithm>
6 #include <cstring> 6 #include <cstring>
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "platform/assert.h" 13 #include "platform/assert.h"
14 #include "vm/unit_test.h" 14 #include "vm/unit_test.h"
15 #include "vm/hash_table.h" 15 #include "vm/hash_table.h"
16 16
17 namespace dart { 17 namespace dart {
18 18
19 // Various ways to look up strings. Uses length as the hash code to make it 19 // Various ways to look up strings. Uses length as the hash code to make it
20 // easy to engineer collisions. 20 // easy to engineer collisions.
21 class TestTraits { 21 class TestTraits {
22 public: 22 public:
23 static const char* Name() { return "TestTraits"; }
24
23 static bool IsMatch(const char* key, const Object& obj) { 25 static bool IsMatch(const char* key, const Object& obj) {
24 return String::Cast(obj).Equals(key); 26 return String::Cast(obj).Equals(key);
25 } 27 }
26 static uword Hash(const char* key) { 28 static uword Hash(const char* key) {
27 return static_cast<uword>(strlen(key)); 29 return static_cast<uword>(strlen(key));
28 } 30 }
29 static bool IsMatch(const Object& a, const Object& b) { 31 static bool IsMatch(const Object& a, const Object& b) {
30 return a.IsString() && b.IsString() && 32 return a.IsString() && b.IsString() &&
31 String::Cast(a).Equals(String::Cast(b)); 33 String::Cast(a).Equals(String::Cast(b));
32 } 34 }
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 TEST_CASE(Maps) { 297 TEST_CASE(Maps) {
296 for (intptr_t initial_capacity = 0; 298 for (intptr_t initial_capacity = 0;
297 initial_capacity < 32; 299 initial_capacity < 32;
298 ++initial_capacity) { 300 ++initial_capacity) {
299 TestMap<UnorderedHashMap<TestTraits> >(initial_capacity, false); 301 TestMap<UnorderedHashMap<TestTraits> >(initial_capacity, false);
300 TestMap<EnumIndexHashMap<TestTraits> >(initial_capacity, true); 302 TestMap<EnumIndexHashMap<TestTraits> >(initial_capacity, true);
301 } 303 }
302 } 304 }
303 305
304 } // namespace dart 306 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698