Skip to content

Commit e00f32f

Browse files
authored
Utilize new Object.hash function instead of quiver code (#2868)
1 parent 55ca10f commit e00f32f

File tree

5 files changed

+5
-56
lines changed

5 files changed

+5
-56
lines changed

lib/src/matching_link_result.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import 'package:dartdoc/src/model/comment_referable.dart';
66
import 'package:dartdoc/src/model/model.dart';
7-
import 'package:dartdoc/src/quiver.dart';
87

98
class MatchingLinkResult {
109
final CommentReferable? commentReferable;
@@ -20,7 +19,7 @@ class MatchingLinkResult {
2019
}
2120

2221
@override
23-
int get hashCode => hash2(commentReferable, warn);
22+
int get hashCode => Object.hash(commentReferable, warn);
2423

2524
@override
2625
String toString() {

lib/src/quiver.dart

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,3 @@
1111
/// The returned iterable is a lazily-evaluated view on the input iterables.
1212
Iterable<T> concat<T>(Iterable<Iterable<T>> iterables) =>
1313
iterables.expand((x) => x);
14-
15-
// From lib/src/core/hash.dart:
16-
17-
/// Generates a hash code for two objects.
18-
int hash2(Object? a, Object? b) =>
19-
_finish(_combine(_combine(0, a.hashCode), b.hashCode));
20-
21-
/// Generates a hash code for three objects.
22-
int hash3(Object? a, Object? b, Object? c) => _finish(
23-
_combine(_combine(_combine(0, a.hashCode), b.hashCode), c.hashCode));
24-
25-
/// Generates a hash code for four objects.
26-
int hash4(Object? a, Object? b, Object? c, Object? d) => _finish(_combine(
27-
_combine(_combine(_combine(0, a.hashCode), b.hashCode), c.hashCode),
28-
d.hashCode));
29-
30-
// Jenkins hash functions
31-
32-
int _combine(int hash, int value) {
33-
hash = 0x1fffffff & (hash + value);
34-
hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
35-
return hash ^ (hash >> 6);
36-
}
37-
38-
int _finish(int hash) {
39-
hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
40-
hash = hash ^ (hash >> 11);
41-
return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
42-
}

lib/src/tuple.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
// file for details. All rights reserved. Use of this source code is governed
66
// by a BSD-style license that can be found in the LICENSE file.
77

8-
import 'package:dartdoc/src/quiver.dart' as quiver;
9-
108
/// Represents a 2-tuple, or pair.
119
class Tuple2<T1, T2> {
1210
/// Returns the first item of the tuple
@@ -26,7 +24,7 @@ class Tuple2<T1, T2> {
2624
other is Tuple2 && other.item1 == item1 && other.item2 == item2;
2725

2826
@override
29-
int get hashCode => quiver.hash2(item1.hashCode, item2.hashCode);
27+
int get hashCode => Object.hash(item1, item2);
3028
}
3129

3230
/// Represents a 3-tuple, or triple.
@@ -54,8 +52,7 @@ class Tuple3<T1, T2, T3> {
5452
other.item3 == item3;
5553

5654
@override
57-
int get hashCode =>
58-
quiver.hash3(item1.hashCode, item2.hashCode, item3.hashCode);
55+
int get hashCode => Object.hash(item1, item2, item3);
5956
}
6057

6158
/// Represents a 4-tuple, or quadruple.
@@ -87,6 +84,5 @@ class Tuple4<T1, T2, T3, T4> {
8784
other.item4 == item4;
8885

8986
@override
90-
int get hashCode => quiver.hash4(
91-
item1.hashCode, item2.hashCode, item3.hashCode, item4.hashCode);
87+
int get hashCode => Object.hash(item1, item2, item3, item4);
9288
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version: 4.1.0
44
description: A non-interactive HTML documentation generator for Dart source code.
55
homepage: https://github.com/dart-lang/dartdoc
66
environment:
7-
sdk: '>=2.12.0 <3.0.0'
7+
sdk: '>=2.14.0 <3.0.0'
88

99
dependencies:
1010
analyzer: ^2.7.0

test/quiver_test.dart

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,4 @@ void main() {
5454
expect(ab, [1, 2, 3, 4, 5, 6]);
5555
});
5656
});
57-
58-
group('hash', () {
59-
test('hash2 should return an int', () {
60-
var h = hash2('123', 456);
61-
expect(h, isA<int>());
62-
});
63-
64-
test('hash3 should return an int', () {
65-
var h = hash3('123', 456, true);
66-
expect(h, isA<int>());
67-
});
68-
69-
test('hash4 should return an int', () {
70-
var h = hash4('123', 456, true, []);
71-
expect(h, isA<int>());
72-
});
73-
});
7457
}

0 commit comments

Comments
 (0)