Skip to content

Commit

Permalink
⚡ Optimize split
Browse files Browse the repository at this point in the history
  • Loading branch information
z0r0z committed Feb 9, 2024
1 parent 7add30c commit 0e7b157
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
14 changes: 7 additions & 7 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
IETest:testBalanceInERC20() (gas: 62541)
IETest:testBalanceInETH() (gas: 53683)
IETest:testCommandSendERC0() (gas: 117712)
IETest:testCommandSendETH() (gas: 83838)
IETest:testCommandSendUSDC() (gas: 150633)
IETest:testDeploy() (gas: 1799284)
IETest:testCommandSendERC0() (gas: 115797)
IETest:testCommandSendETH() (gas: 82297)
IETest:testCommandSendUSDC() (gas: 148533)
IETest:testDeploy() (gas: 1806509)
IETest:testENSNameFromENSHelper() (gas: 29125)
IETest:testENSNameOwnership() (gas: 109154)
IETest:testIENameSetting() (gas: 8174)
IETest:testPreviewCommandSendDecimals() (gas: 120253)
IETest:testPreviewCommandSendUSDC() (gas: 80750)
IETest:testPreviewCommandSendDecimals() (gas: 114569)
IETest:testPreviewCommandSendUSDC() (gas: 78837)
IETest:testPreviewSend() (gas: 54699)
IETest:testPreviewSendCommand() (gas: 70150)
IETest:testPreviewSendCommand() (gas: 68051)
IETest:testSendETH() (gas: 70975)
IETest:testTotalSupply() (gas: 14810)
12 changes: 7 additions & 5 deletions src/IE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,16 @@ contract IE {
}
string[] memory parts = new string[](count);
uint256 partIndex;
bytes memory tempPart;
uint256 start;
for (uint256 i; i <= baseBytes.length; ++i) {
if (i == baseBytes.length || baseBytes[i] == delimiter) {
parts[partIndex] = string(tempPart);
bytes memory part = new bytes(i - start);
for (uint256 j = start; j != i; ++j) {
part[j - start] = baseBytes[j];
}
parts[partIndex] = string(part);
++partIndex;
tempPart = "";
} else {
tempPart = abi.encodePacked(tempPart, baseBytes[i]);
start = i + 1;
}
}
return parts;
Expand Down

0 comments on commit 0e7b157

Please sign in to comment.