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

Unified Diff: pkg/compiler/lib/src/util/util.dart

Issue 1062913003: Extract CallStructure from Selector. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix expentancy in unittest Created 5 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/util/util.dart
diff --git a/pkg/compiler/lib/src/util/util.dart b/pkg/compiler/lib/src/util/util.dart
index 7c75819b0fce6878963aae11408dd79cad85ea41..b825d186725e2571d67cd2c1b853f17df4becd2f 100644
--- a/pkg/compiler/lib/src/util/util.dart
+++ b/pkg/compiler/lib/src/util/util.dart
@@ -18,6 +18,23 @@ part 'link.dart';
/// Smi range.
const int SMI_MASK = 0x3fffffff;
+/// Mix the bits of [value] and merge them with [existing].
+int mixHashCodeBits(int existing, int value) {
+ // Spread the bits of value. Try to stay in the 30-bit range to
+ // avoid overflowing into a more expensive integer representation.
+ int h = value & 0x1fffffff;
+ h += ((h & 0x3fff) << 15) ^ 0x1fffcd7d;
+ h ^= (h >> 10);
+ h += ((h & 0x3ffffff) << 3);
+ h ^= (h >> 6);
+ h += ((h & 0x7ffffff) << 2) + ((h & 0x7fff) << 14);
+ h ^= (h >> 16);
+ // Combine the two hash values.
+ int high = existing >> 15;
+ int low = existing & 0x7fff;
+ return ((high * 13) ^ (low * 997) ^ h) & SMI_MASK;
+}
+
/**
* Tagging interface for classes from which source spans can be generated.
*/
« no previous file with comments | « pkg/compiler/lib/src/use_unused_api.dart ('k') | tests/compiler/dart2js/backend_dart/sexpr_unstringifier.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698