Skip to content

Commit

Permalink
memory-safe and minor bool optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
0age committed Oct 17, 2024
1 parent a5b50a0 commit 240249f
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 56 deletions.
8 changes: 4 additions & 4 deletions src/TheCompact.sol
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ contract TheCompact is ITheCompact, ERC6909, Extsload {
bool firstUnderlyingTokenIsNative;
uint256 id;

assembly {
assembly ("memory-safe") {
let idsAndAmountsOffset := idsAndAmounts.offset
id := calldataload(idsAndAmountsOffset)
firstUnderlyingTokenIsNative := iszero(shr(96, shl(96, id)))
Expand Down Expand Up @@ -343,7 +343,7 @@ contract TheCompact is ITheCompact, ERC6909, Extsload {
) external payable returns (uint256[] memory) {
uint256 totalTokens = permitted.length;
bool firstUnderlyingTokenIsNative;
assembly {
assembly ("memory-safe") {
let permittedOffset := permitted.offset
firstUnderlyingTokenIsNative := iszero(shr(96, shl(96, add(permittedOffset, 0x20))))

Expand Down Expand Up @@ -1171,7 +1171,7 @@ contract TheCompact is ITheCompact, ERC6909, Extsload {
}

function _emitClaim(address sponsor, bytes32 messageHash, address allocator) internal {
assembly {
assembly ("memory-safe") {
mstore(0, messageHash)
log4(
0,
Expand Down Expand Up @@ -1702,7 +1702,7 @@ contract TheCompact is ITheCompact, ERC6909, Extsload {
IAllocator(allocator).attest(msg.sender, from, to, id, amount)
!= IAllocator.attest.selector
) {
assembly {
assembly ("memory-safe") {
// revert UnallocatedTransfer(msg.sender, from, to, id, amount)
mstore(0, 0x014c9310)
mstore(0x20, caller())
Expand Down
68 changes: 34 additions & 34 deletions src/lib/FunctionCastLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ library FunctionCastLib {
pure
returns (function (bytes32, address, SplitTransfer calldata) internal view fnOut)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -56,7 +56,7 @@ library FunctionCastLib {
pure
returns (function (bytes32, address, BatchTransfer calldata) internal view fnOut)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -68,7 +68,7 @@ library FunctionCastLib {
pure
returns (function (bytes32, address, SplitBatchTransfer calldata) internal view fnOut)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -82,7 +82,7 @@ library FunctionCastLib {
function(SplitBatchTransfer calldata, bytes32) internal view returns (bytes32) fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -96,7 +96,7 @@ library FunctionCastLib {
function(QualifiedSplitClaim calldata) internal view returns (bytes32, bytes32) fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -110,7 +110,7 @@ library FunctionCastLib {
function(QualifiedClaimWithWitness calldata, uint256) internal view returns (bytes32) fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -127,7 +127,7 @@ library FunctionCastLib {
returns (bytes32) fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -144,7 +144,7 @@ library FunctionCastLib {
returns (bytes32) fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -161,7 +161,7 @@ library FunctionCastLib {
returns (bytes32) fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -178,7 +178,7 @@ library FunctionCastLib {
returns (bytes32) fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -195,7 +195,7 @@ library FunctionCastLib {
returns (bytes32) fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -210,7 +210,7 @@ library FunctionCastLib {
fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -226,7 +226,7 @@ library FunctionCastLib {
fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -242,7 +242,7 @@ library FunctionCastLib {
fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -258,7 +258,7 @@ library FunctionCastLib {
fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -274,7 +274,7 @@ library FunctionCastLib {
fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -284,7 +284,7 @@ library FunctionCastLib {
pure
returns (function (SplitClaim calldata) internal view returns (bytes32) fnOut)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -298,7 +298,7 @@ library FunctionCastLib {
function (SplitClaimWithWitness calldata, uint256) internal view returns (bytes32) fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -311,7 +311,7 @@ library FunctionCastLib {
pure
returns (function (SplitByIdComponent[] memory, uint256) internal returns (address) fnOut)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -323,7 +323,7 @@ library FunctionCastLib {
pure
returns (function (bytes32, ClaimWithWitness calldata, address) internal view fnOut)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -335,7 +335,7 @@ library FunctionCastLib {
pure
returns (function(bytes32, SplitClaimWithWitness calldata, address) internal view fnOut)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -345,7 +345,7 @@ library FunctionCastLib {
pure
returns (function(bytes32, SplitClaim calldata, address) internal view fnOut)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -355,7 +355,7 @@ library FunctionCastLib {
pure
returns (function(bytes32, BatchClaim calldata, address) internal view fnOut)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -367,7 +367,7 @@ library FunctionCastLib {
pure
returns (function(bytes32, SplitBatchClaim calldata, address) internal view fnOut)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -381,7 +381,7 @@ library FunctionCastLib {
function(bytes32, SplitBatchClaimWithWitness calldata, address) internal view fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -393,7 +393,7 @@ library FunctionCastLib {
pure
returns (function(bytes32, BatchClaimWithWitness calldata, address) internal view fnOut)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -405,7 +405,7 @@ library FunctionCastLib {
pure
returns (function(QualifiedSplitClaim calldata) internal returns (bytes32, address) fnOut)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -419,7 +419,7 @@ library FunctionCastLib {
function (bytes32, bytes32, QualifiedClaimWithWitness calldata, address) internal view fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -433,7 +433,7 @@ library FunctionCastLib {
function (bytes32, bytes32, QualifiedBatchClaim calldata, address) internal view fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -447,7 +447,7 @@ library FunctionCastLib {
function (bytes32, bytes32, QualifiedSplitBatchClaim calldata, address) internal view fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -462,7 +462,7 @@ library FunctionCastLib {
fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -477,7 +477,7 @@ library FunctionCastLib {
fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -491,7 +491,7 @@ library FunctionCastLib {
function(QualifiedSplitClaimWithWitness calldata) internal returns (bytes32, address) fnOut
)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand All @@ -503,7 +503,7 @@ library FunctionCastLib {
pure
returns (function(bytes32, MultichainClaim calldata, address) internal view fnOut)
{
assembly {
assembly ("memory-safe") {
fnOut := fnIn
}
}
Expand Down
Loading

0 comments on commit 240249f

Please sign in to comment.