Files
sdk/tests/language/value_class/value_class_support_lib.dart
T
jlcontreras 42c4c3c1bd [cfe] Add Jenkins SMI hashcode combiner
Change-Id: I542369fc2d8443bb0094fdedc11596fdc2f20e2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159084
Commit-Queue: Javier López-Contreras <jlcontreras@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-09-07 12:36:13 +00:00

22 lines
792 B
Dart

// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// TODO(jlcontreras): this is a temp file for the valueClass experiment
const valueClass = "valueClass";
/// This code is from the dart.math sdk/lib/math/jenkins_smi_hash.dart
class JenkinsSmiHash {
static int combine(int hash, int value) {
hash = 0x1fffffff & (hash + value);
hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
return hash ^ (hash >> 6);
}
static int finish(int hash) {
hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
hash = hash ^ (hash >> 11);
return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
}
}