Skip to content

Commit 04e12bb

Browse files
committed
add static helpers and use tearoffs
1 parent 314c1e1 commit 04e12bb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pkgs/collection/lib/src/equality.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,14 @@ class MapEquality<K, V> implements Equality<Map<K, V>> {
329329
for (var key in map1.keys) {
330330
var value = (values1..moveNext()).current;
331331
var entry = _MapEntry(this, key, value);
332-
equalElementCounts.update(entry, (i) => i + 1, ifAbsent: () => 1);
332+
equalElementCounts.update(entry, _addOne, ifAbsent: _one);
333333
}
334334
final values2 = map2.values.iterator;
335335
for (var key in map2.keys) {
336336
var value = (values2..moveNext()).current;
337337
var entry = _MapEntry(this, key, value);
338-
var count =
339-
equalElementCounts.update(entry, (i) => i - 1, ifAbsent: () => -1);
338+
var count = equalElementCounts.update(entry, _subtractOne,
339+
ifAbsent: _negativeOne);
340340
if (count < 0) return false;
341341
}
342342
return true;
@@ -494,3 +494,8 @@ class CaseInsensitiveEquality implements Equality<String> {
494494
@override
495495
bool isValidKey(Object? object) => object is String;
496496
}
497+
498+
int _addOne(int i) => i + 1;
499+
int _subtractOne(int i) => i - 1;
500+
int _one() => 1;
501+
int _negativeOne() => -1;

0 commit comments

Comments
 (0)