Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/helpers/EmptyCalldataSlice.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;

function getEmptyCalldataSlice() pure returns (bytes calldata) {
bytes calldata empty;

assembly ("memory-safe") {
empty.length := 0
}

return empty;
}
5 changes: 3 additions & 2 deletions src/libraries/SparseCalldataSegmentLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.20;

import {RESERVED_VALIDATION_DATA_INDEX} from "../helpers/Constants.sol";
import {getEmptyCalldataSlice} from "../helpers/EmptyCalldataSlice.sol";

/// @title Sparse Calldata Segment Library
/// @notice Library for working with sparsely-packed calldata segments, identified with an index.
Expand Down Expand Up @@ -51,7 +52,7 @@ library SparseCalldataSegmentLib {
function advanceSegmentIfAtIndex(bytes calldata source, uint8 index)
internal
pure
returns (bytes memory, bytes calldata)
returns (bytes calldata, bytes calldata)
{
uint8 nextIndex = getIndex(source);

Expand All @@ -69,7 +70,7 @@ library SparseCalldataSegmentLib {
return (segment, remainder);
}

return ("", source);
return (getEmptyCalldataSlice(), source);
}

/// @notice Extracts the final segment from the source.
Expand Down