Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0043ef2

Browse files
committedAug 14, 2024··
refactor: use getters
1 parent 5cfa1a6 commit 0043ef2

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed
 

‎certora/applyHarnessFifo.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
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
44
@@ -16,6 +16,8 @@
55

66
struct List {
@@ -15,11 +15,11 @@ diff -ruN DoubleLinkedList.sol DoubleLinkedList.sol
1515
for (; numberOfIterations < maxIterations; numberOfIterations++) {
1616
if (next == address(0) || list.accounts[next].value < value) break;
1717
+ list.insertedAfter = next; // HARNESS
18-
next = list.accounts[next].next;
18+
next = getNext(list, next);
1919
}
2020

2121
if (numberOfIterations == maxIterations) next = address(0);
2222
+ list.insertedBefore = next; // HARNESS
2323

24-
address prev = list.accounts[next].prev;
24+
address prev = getPrev(list, next);
2525
list.accounts[id] = Account(prev, next, value);

‎certora/applyHarnessSimple.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
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
44
@@ -16,6 +16,8 @@
55

66
struct List {
@@ -21,18 +21,18 @@ diff -ruN DoubleLinkedList.sol DoubleLinkedList.sol
2121
if (id == address(0)) revert AddressIsZero();
2222
if (list.accounts[id].value != 0) revert AccountAlreadyInserted();
2323

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`.
2525

2626
- uint256 numberOfIterations;
2727
- for (; numberOfIterations < maxIterations; numberOfIterations++) {
2828
+ for (;;) {
2929
if (next == address(0) || list.accounts[next].value < value) break;
3030
+ list.insertedAfter = next; // HARNESS
31-
next = list.accounts[next].next;
31+
next = getNext(list, next);
3232
}
3333

3434
- if (numberOfIterations == maxIterations) next = address(0);
3535
+ list.insertedBefore = next; // HARNESS
3636

37-
address prev = list.accounts[next].prev;
37+
address prev = getPrev(list, next);
3838
list.accounts[id] = Account(prev, next, value);

‎src/DoubleLinkedList.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,17 @@ library DoubleLinkedList {
9696
if (id == address(0)) revert AddressIsZero();
9797
if (list.accounts[id].value != 0) revert AccountAlreadyInserted();
9898

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`.
100100

101101
uint256 numberOfIterations;
102102
for (; numberOfIterations < maxIterations; numberOfIterations++) {
103103
if (next == address(0) || list.accounts[next].value < value) break;
104-
next = list.accounts[next].next;
104+
next = getNext(list, next);
105105
}
106106

107107
if (numberOfIterations == maxIterations) next = address(0);
108108

109-
address prev = list.accounts[next].prev;
109+
address prev = getPrev(list, next);
110110
list.accounts[id] = Account(prev, next, value);
111111
list.accounts[prev].next = id;
112112
list.accounts[next].prev = id;

0 commit comments

Comments
 (0)
Please sign in to comment.