Skip to content

Commit

Permalink
chore: Minor gas optimization (#841)
Browse files Browse the repository at this point in the history
* chore: Minor gas optimizaiton

Trying out this minor gas optimization where nested ifs are better than multiple &&

* formatted

* change bytecode snap

* snapshots

* snap
  • Loading branch information
mr-uniswap authored Aug 23, 2024
1 parent e8e63c8 commit 12a1d64
Show file tree
Hide file tree
Showing 18 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/poolManager bytecode size.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24304
24357
2 changes: 1 addition & 1 deletion .forge-snapshots/simple swap with native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
109245
109230
2 changes: 1 addition & 1 deletion .forge-snapshots/simple swap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
124091
124076
2 changes: 1 addition & 1 deletion .forge-snapshots/swap CA custom curve + swap noop.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
126932
126914
2 changes: 1 addition & 1 deletion .forge-snapshots/swap CA fee on unspecified.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
155536
155521
Original file line number Diff line number Diff line change
@@ -1 +1 @@
106203
106188
2 changes: 1 addition & 1 deletion .forge-snapshots/swap against liquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
117297
117282
2 changes: 1 addition & 1 deletion .forge-snapshots/swap burn 6909 for input.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
129411
129396
2 changes: 1 addition & 1 deletion .forge-snapshots/swap burn native 6909 for input.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
118873
118858
2 changes: 1 addition & 1 deletion .forge-snapshots/swap mint native output as 6909.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
140238
140223
2 changes: 1 addition & 1 deletion .forge-snapshots/swap mint output as 6909.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
155932
155917
Original file line number Diff line number Diff line change
@@ -1 +1 @@
207788
207758
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with dynamic fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
140124
140109
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with hooks.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
132935
132920
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with lp fee and protocol fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
169947
169932
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with return dynamic fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
146451
146436
2 changes: 1 addition & 1 deletion .forge-snapshots/update dynamic fee in before swap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
148731
148716
6 changes: 4 additions & 2 deletions src/libraries/Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,10 @@ library Pool {

bool exactInput = params.amountSpecified < 0;

if (swapFee == LPFeeLibrary.MAX_LP_FEE && !exactInput) {
InvalidFeeForExactOut.selector.revertWith();
if (swapFee == LPFeeLibrary.MAX_LP_FEE) {
if (!exactInput) {
InvalidFeeForExactOut.selector.revertWith();
}
}

if (params.amountSpecified == 0) return (BalanceDeltaLibrary.ZERO_DELTA, 0, swapFee, state);
Expand Down

0 comments on commit 12a1d64

Please sign in to comment.