blob: f0b6de46d70b271f0c56dddec48b2b61a1c47218 [file] [log] [blame]
// Copyright (c) 2015, 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.
library dart_style.src.fast_hash;
/// A mixin for classes with identity equality that need to be frequently
/// hashed.
abstract class FastHash {
static int _nextId = 0;
/// A semi-unique numeric indentifier for the object.
///
/// This is useful for debugging and also speeds up using the object in hash
/// sets. Ids are *semi*-unique because they may wrap around in long running
/// processes. Since objects are equal based on their identity, this is
/// innocuous and prevents ids from growing without bound.
final int id = _nextId = (_nextId + 1) & 0x0fffffff;
int get hashCode => id;
}