Skip to content

Commit

Permalink
remove unnecessary length check (#406)
Browse files Browse the repository at this point in the history
* remove unnecessary length check

* comments for clarity

---------

Co-authored-by: Sara Reynolds <[email protected]>
  • Loading branch information
hensha256 and snreynolds authored Dec 2, 2024
1 parent d6b0bd0 commit 05ede29
Show file tree
Hide file tree
Showing 19 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_collect_native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
148593
148571
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_collect_sameRange.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
157242
157220
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_collect_withClose.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
157242
157220
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_collect_withTakePair.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
156478
156456
Original file line number Diff line number Diff line change
@@ -1 +1 @@
114183
114165
Original file line number Diff line number Diff line change
@@ -1 +1 @@
122577
122555
Original file line number Diff line number Diff line change
@@ -1 +1 @@
121813
121791
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_decrease_burnEmpty.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
138195
138177
Original file line number Diff line number Diff line change
@@ -1 +1 @@
131276
131258
Original file line number Diff line number Diff line change
@@ -1 +1 @@
135240
135218
2 changes: 1 addition & 1 deletion .forge-snapshots/PositionManager_decrease_take_take.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
123191
123169
Original file line number Diff line number Diff line change
@@ -1 +1 @@
162441
162419
Original file line number Diff line number Diff line change
@@ -1 +1 @@
161305
161283
Original file line number Diff line number Diff line change
@@ -1 +1 @@
145318
145296
Original file line number Diff line number Diff line change
@@ -1 +1 @@
138032
138010
Original file line number Diff line number Diff line change
@@ -1 +1 @@
180216
180194
Original file line number Diff line number Diff line change
@@ -1 +1 @@
150804
150782
2 changes: 1 addition & 1 deletion .forge-snapshots/positionManager bytecode size.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19068
19060
9 changes: 5 additions & 4 deletions src/libraries/CalldataDecoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,8 @@ library CalldataDecoder {
pure
returns (uint256 tokenId, uint256 liquidity, uint128 amount0, uint128 amount1, bytes calldata hookData)
{
// no length check performed, as there is a length check in `toBytes`
assembly ("memory-safe") {
if lt(params.length, 0x80) {
mstore(0, SLICE_ERROR_SELECTOR)
revert(0x1c, 4)
}
tokenId := calldataload(params.offset)
liquidity := calldataload(add(params.offset, 0x20))
amount0 := calldataload(add(params.offset, 0x40))
Expand All @@ -96,6 +93,7 @@ library CalldataDecoder {
pure
returns (uint256 tokenId, uint128 amount0Max, uint128 amount1Max, bytes calldata hookData)
{
// no length check performed, as there is a length check in `toBytes`
assembly ("memory-safe") {
tokenId := calldataload(params.offset)
amount0Max := calldataload(add(params.offset, 0x20))
Expand All @@ -120,6 +118,7 @@ library CalldataDecoder {
bytes calldata hookData
)
{
// no length check performed, as there is a length check in `toBytes`
assembly ("memory-safe") {
poolKey := params.offset
tickLower := calldataload(add(params.offset, 0xa0))
Expand All @@ -146,6 +145,7 @@ library CalldataDecoder {
bytes calldata hookData
)
{
// no length check performed, as there is a length check in `toBytes`
assembly ("memory-safe") {
poolKey := params.offset
tickLower := calldataload(add(params.offset, 0xa0))
Expand All @@ -164,6 +164,7 @@ library CalldataDecoder {
pure
returns (uint256 tokenId, uint128 amount0Min, uint128 amount1Min, bytes calldata hookData)
{
// no length check performed, as there is a length check in `toBytes`
assembly ("memory-safe") {
tokenId := calldataload(params.offset)
amount0Min := calldataload(add(params.offset, 0x20))
Expand Down

0 comments on commit 05ede29

Please sign in to comment.