File tree Expand file tree Collapse file tree 3 files changed +12
-12
lines changed Expand file tree Collapse file tree 3 files changed +12
-12
lines changed Original file line number Diff line number Diff line change 1
1
diff -ruN DoubleLinkedList.sol DoubleLinkedList.sol
2
- --- DoubleLinkedList.sol 2024-07-12 09:49:49.899261374 +0200
3
- +++ DoubleLinkedList.sol 2024-07-12 09:53:11.964303440 +0200
2
+ --- DoubleLinkedList.sol 2024-08-14 10:10:08.974975205 +0200
3
+ +++ DoubleLinkedList.sol 2024-08-14 10:14:10.970436843 +0200
4
4
@@ -16,6 +16,8 @@
5
5
6
6
struct List {
@@ -15,11 +15,11 @@ diff -ruN DoubleLinkedList.sol DoubleLinkedList.sol
15
15
for (; numberOfIterations < maxIterations; numberOfIterations++) {
16
16
if (next == address(0) || list.accounts[next].value < value) break;
17
17
+ list.insertedAfter = next; // HARNESS
18
- next = list.accounts[ next].next ;
18
+ next = getNext( list, next) ;
19
19
}
20
20
21
21
if (numberOfIterations == maxIterations) next = address(0);
22
22
+ list.insertedBefore = next; // HARNESS
23
23
24
- address prev = list.accounts[ next].prev ;
24
+ address prev = getPrev( list, next) ;
25
25
list.accounts[id] = Account(prev, next, value);
Original file line number Diff line number Diff line change 1
1
diff -ruN DoubleLinkedList.sol DoubleLinkedList.sol
2
- --- DoubleLinkedList.sol 2024-07-12 09:49:49.899261374 +0200
3
- +++ DoubleLinkedList.sol 2024-07-12 09:52:16.333105454 +0200
2
+ --- DoubleLinkedList.sol 2024-08-14 10:10:08.974975205 +0200
3
+ +++ DoubleLinkedList.sol 2024-08-14 10:13:25.455164370 +0200
4
4
@@ -16,6 +16,8 @@
5
5
6
6
struct List {
@@ -21,18 +21,18 @@ diff -ruN DoubleLinkedList.sol DoubleLinkedList.sol
21
21
if (id == address(0)) revert AddressIsZero();
22
22
if (list.accounts[id].value != 0) revert AccountAlreadyInserted();
23
23
24
- address next = list.accounts[address(0)].next ; // `id` will be inserted before `next`.
24
+ address next = getHead(list) ; // `id` will be inserted before `next`.
25
25
26
26
- uint256 numberOfIterations;
27
27
- for (; numberOfIterations < maxIterations; numberOfIterations++) {
28
28
+ for (;;) {
29
29
if (next == address(0) || list.accounts[next].value < value) break;
30
30
+ list.insertedAfter = next; // HARNESS
31
- next = list.accounts[ next].next ;
31
+ next = getNext( list, next) ;
32
32
}
33
33
34
34
- if (numberOfIterations == maxIterations) next = address(0);
35
35
+ list.insertedBefore = next; // HARNESS
36
36
37
- address prev = list.accounts[ next].prev ;
37
+ address prev = getPrev( list, next) ;
38
38
list.accounts[id] = Account(prev, next, value);
Original file line number Diff line number Diff line change @@ -96,17 +96,17 @@ library DoubleLinkedList {
96
96
if (id == address (0 )) revert AddressIsZero ();
97
97
if (list.accounts[id].value != 0 ) revert AccountAlreadyInserted ();
98
98
99
- address next = list.accounts[ address ( 0 )].next ; // `id` will be inserted before `next`.
99
+ address next = getHead (list) ; // `id` will be inserted before `next`.
100
100
101
101
uint256 numberOfIterations;
102
102
for (; numberOfIterations < maxIterations; numberOfIterations++ ) {
103
103
if (next == address (0 ) || list.accounts[next].value < value) break ;
104
- next = list.accounts[ next].next ;
104
+ next = getNext ( list, next) ;
105
105
}
106
106
107
107
if (numberOfIterations == maxIterations) next = address (0 );
108
108
109
- address prev = list.accounts[ next].prev ;
109
+ address prev = getPrev ( list, next) ;
110
110
list.accounts[id] = Account (prev, next, value);
111
111
list.accounts[prev].next = id;
112
112
list.accounts[next].prev = id;
You can’t perform that action at this time.
0 commit comments