Commit b6b7eac
authored
refactor(levm): remove unneeded checks in swap (#5305)
**Motivation**
Currently for swapN we do two unnecessary checks:
- `stack.len() < N`, which is also done inside `Stack::swap`
- checked add of offset (stack depth) and N, which is guaranteed to
never fail as N and the offset are both bounded
**Description**
Checking that `offset + N >= STACK_DEPTH` should be enough.1 parent 2690a53 commit b6b7eac
File tree
2 files changed
+11
-10
lines changed- crates/vm/levm/src
- opcode_handlers
2 files changed
+11
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
152 | 156 | | |
153 | 157 | | |
154 | 158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 16 | + | |
20 | 17 | | |
21 | 18 | | |
22 | 19 | | |
| |||
0 commit comments