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

Unified Diff: runtime/lib/compact_hash.dart

Issue 946893002: Ensure hash pattern is non-zero. Re-enable compact hash map/set. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/lib/linked_hash_map.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/compact_hash.dart
===================================================================
--- runtime/lib/compact_hash.dart (revision 43939)
+++ runtime/lib/compact_hash.dart (working copy)
@@ -32,11 +32,13 @@
int _hashMask = int.is64Bit() ?
(1 << (32 - _INITIAL_INDEX_BITS)) - 1 :
(1 << (30 - _INITIAL_INDEX_BITS)) - 1;
-
- static int _hashPattern(int fullHash, int hashMask, int size) =>
- // TODO(koda): Consider keeping bit length and use left shift.
- (fullHash == 0) ? (size >> 1) : (fullHash & hashMask) * (size >> 1);
+ static int _hashPattern(int fullHash, int hashMask, int size) {
+ final int maskedHash = fullHash & hashMask;
+ // TODO(koda): Consider keeping bit length and use left shift.
+ return (maskedHash == 0) ? (size >> 1) : maskedHash * (size >> 1);
+ }
+
// Linear probing.
static int _firstProbe(int fullHash, int sizeMask) {
final int i = fullHash & sizeMask;
@@ -124,7 +126,7 @@
_rehash();
this[key] = value;
} else {
- assert(0 <= hashPattern && hashPattern < (1 << 32));
+ assert(1 <= hashPattern && hashPattern < (1 << 32));
final int index = _usedData >> 1;
assert((index & hashPattern) == 0);
_index[i] = hashPattern | index;
@@ -403,7 +405,7 @@
add(key);
} else {
final int insertionPoint = (firstDeleted >= 0) ? firstDeleted : i;
- assert(0 <= hashPattern && hashPattern < (1 << 32));
+ assert(1 <= hashPattern && hashPattern < (1 << 32));
assert((hashPattern & _usedData) == 0);
_index[insertionPoint] = hashPattern | _usedData;
_data[_usedData++] = key;
« no previous file with comments | « no previous file | runtime/lib/linked_hash_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698