This repository was archived by the owner on Dec 17, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathapplyHarnessSimple.patch
More file actions
38 lines (32 loc) · 1.63 KB
/
applyHarnessSimple.patch
File metadata and controls
38 lines (32 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
diff -ruN DoubleLinkedList.sol DoubleLinkedList.sol
--- DoubleLinkedList.sol
+++ DoubleLinkedList.sol
@@ -16,6 +16,8 @@
struct List {
mapping(address => Account) accounts;
+ address insertedBefore; // HARNESS: address of the account before which the account was inserted at last insertion.
+ address insertedAfter; // HARNESS: address of the account after which the account was inserted at last insertion.
}
/* ERRORS */
@@ -90,21 +92,20 @@
/// @param list The list to search in.
/// @param id The address of the account.
/// @param value The value of the account.
- /// @param maxIterations The max number of iterations.
- function insertSorted(List storage list, address id, uint256 value, uint256 maxIterations) internal {
+ function insertSorted(List storage list, address id, uint256 value) internal {
if (value == 0) revert ValueIsZero();
if (id == address(0)) revert AddressIsZero();
if (list.accounts[id].value != 0) revert AccountAlreadyInserted();
address next = getHead(list); // `id` will be inserted before `next`.
- uint256 numberOfIterations;
- for (; numberOfIterations < maxIterations; numberOfIterations++) {
+ for (;;) {
if (next == address(0) || list.accounts[next].value < value) break;
+ list.insertedAfter = next; // HARNESS
next = getNext(list, next);
}
- if (numberOfIterations == maxIterations) next = address(0);
+ list.insertedBefore = next; // HARNESS
address prev = getPrev(list, next);
list.accounts[id] = Account(prev, next, value);