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

Side by Side Diff: runtime/platform/utils.cc

Issue 9186035: Use hash map for event handler file descriptor map (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r3482 Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/hashmap_test.cc ('k') | tests/standalone/src/ProcessStderrTest.dart » ('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 #include "platform/utils.h" 5 #include "platform/utils.h"
6 6
7 namespace dart { 7 namespace dart {
8 8
9 // Implementation is from "Hacker's Delight" by Henry S. Warren, Jr., 9 // Implementation is from "Hacker's Delight" by Henry S. Warren, Jr.,
10 // figure 3-3, page 48, where the function is called clp2. 10 // figure 3-3, page 48, where the function is called clp2.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 // Do a few final mixes of the hash to ensure the last few bytes are 69 // Do a few final mixes of the hash to ensure the last few bytes are
70 // well-incorporated. 70 // well-incorporated.
71 hash ^= hash >> 13; 71 hash ^= hash >> 13;
72 hash *= M; 72 hash *= M;
73 hash ^= hash >> 15; 73 hash ^= hash >> 15;
74 return hash; 74 return hash;
75 } 75 }
76 76
77 77
78 uint32_t WordHash(word key) { 78 uint32_t Utils::WordHash(word key) {
79 // TODO(iposva): Need to check hash spreading. 79 // TODO(iposva): Need to check hash spreading.
80 // This example is from http://www.concentric.net/~Ttwang/tech/inthash.htm 80 // This example is from http://www.concentric.net/~Ttwang/tech/inthash.htm
81 uword a = static_cast<uword>(key); 81 uword a = static_cast<uword>(key);
82 a = (a + 0x7ed55d16) + (a << 12); 82 a = (a + 0x7ed55d16) + (a << 12);
83 a = (a ^ 0xc761c23c) ^ (a >> 19); 83 a = (a ^ 0xc761c23c) ^ (a >> 19);
84 a = (a + 0x165667b1) + (a << 5); 84 a = (a + 0x165667b1) + (a << 5);
85 a = (a + 0xd3a2646c) ^ (a << 9); 85 a = (a + 0xd3a2646c) ^ (a << 9);
86 a = (a + 0xfd7046c5) + (a << 3); 86 a = (a + 0xfd7046c5) + (a << 3);
87 a = (a ^ 0xb55a4f09) ^ (a >> 16); 87 a = (a ^ 0xb55a4f09) ^ (a >> 16);
88 return static_cast<uint32_t>(a); 88 return static_cast<uint32_t>(a);
89 } 89 }
90 90
91 } // namespace dart 91 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/hashmap_test.cc ('k') | tests/standalone/src/ProcessStderrTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698