OLD | NEW |
| (Empty) |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 library dart_style.src.fast_hash; | |
6 | |
7 /// A mixin for classes with identity equality that need to be frequently | |
8 /// hashed. | |
9 abstract class FastHash { | |
10 static int _nextId = 0; | |
11 | |
12 /// A semi-unique numeric indentifier for the object. | |
13 /// | |
14 /// This is useful for debugging and also speeds up using the object in hash | |
15 /// sets. Ids are *semi*-unique because they may wrap around in long running | |
16 /// processes. Since objects are equal based on their identity, this is | |
17 /// innocuous and prevents ids from growing without bound. | |
18 final int id = _nextId = (_nextId + 1) & 0x0fffffff; | |
19 | |
20 int get hashCode => id; | |
21 } | |
OLD | NEW |