Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit f4132ea

Browse files
committed
refactor(dccd): Drop the insertBefore arg from DuplicateMap.put()
Closes #1128 The insertBefore argument is never used in the current code
1 parent 9f0c7bc commit f4132ea

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

lib/change_detection/dirty_checking_change_detector.dart

+8-26
Original file line numberDiff line numberDiff line change
@@ -1320,39 +1320,21 @@ class _DuplicateItemRecordList {
13201320
ItemRecord _head, _tail;
13211321

13221322
/**
1323-
* Add the [record] before the [insertBefore] in the list of duplicates or at the end of the list
1324-
* when no [insertBefore] is specified.
1323+
* Append the [record] to the list of duplicates.
13251324
*
13261325
* Note: by design all records in the list of duplicates hold the save value in [record.item].
13271326
*/
1328-
void add(ItemRecord record, ItemRecord insertBefore) {
1329-
assert(insertBefore == null || insertBefore.item == record.item);
1327+
void add(ItemRecord record) {
13301328
if (_head == null) {
1331-
/// pushing the first [ItemRecord] to the list
1332-
assert(insertBefore == null);
13331329
_head = _tail = record;
13341330
record._nextDup = null;
13351331
record._prevDup = null;
13361332
} else {
1337-
// adding a duplicate [ItemRecord] to the list
13381333
assert(record.item == _head.item);
1339-
if (insertBefore == null) {
1340-
_tail._nextDup = record;
1341-
record._prevDup = _tail;
1342-
record._nextDup = null;
1343-
_tail = record;
1344-
} else {
1345-
var prev = insertBefore._prevDup;
1346-
var next = insertBefore;
1347-
record._prevDup = prev;
1348-
record._nextDup = next;
1349-
if (prev == null) {
1350-
_head = record;
1351-
} else {
1352-
prev._nextDup = record;
1353-
}
1354-
next._prevDup = record;
1355-
}
1334+
_tail._nextDup = record;
1335+
record._prevDup = _tail;
1336+
record._nextDup = null;
1337+
_tail = record;
13561338
}
13571339
}
13581340

@@ -1408,8 +1390,8 @@ class _DuplicateItemRecordList {
14081390
class DuplicateMap {
14091391
final map = <dynamic, _DuplicateItemRecordList>{};
14101392

1411-
void put(ItemRecord record, [ItemRecord insertBefore = null]) {
1412-
map.putIfAbsent(record.item, () => new _DuplicateItemRecordList()).add(record, insertBefore);
1393+
void put(ItemRecord record) {
1394+
map.putIfAbsent(record.item, () => new _DuplicateItemRecordList()).add(record);
14131395
}
14141396

14151397
/**

0 commit comments

Comments
 (0)