Skip to content

Commit

Permalink
⚡ Optimize len
Browse files Browse the repository at this point in the history
  • Loading branch information
z0r0z committed Feb 9, 2024
1 parent f9e8916 commit 0c0e75a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
IETest:testBalanceIn() (gas: 61352)
IETest:testDeploy() (gas: 1812338)
IETest:testDeploy() (gas: 1811938)
IETest:testNameFromHelper() (gas: 29061)
IETest:testNameOwnership() (gas: 109019)
IETest:testNameSetting() (gas: 8174)
IETest:testPreviewCommand() (gas: 79206)
IETest:testPreviewCommandDecimals() (gas: 145486)
IETest:testPreviewCommand() (gas: 79033)
IETest:testPreviewCommandDecimals() (gas: 145004)
IETest:testTotalSupply() (gas: 14695)
7 changes: 4 additions & 3 deletions src/IE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,13 @@ contract IE {
returns (string memory)
{
unchecked {
uint256 len = bytes(base).length;
bytes memory baseBytes = bytes(base);
bytes memory result = new bytes(baseBytes.length + 1);
for (uint256 i; i != baseBytes.length; ++i) {
bytes memory result = new bytes(len + 1);
for (uint256 i; i != len; ++i) {
result[i] = baseBytes[i];
}
result[baseBytes.length] = value;
result[len] = value;
return string(result);
}
}
Expand Down

0 comments on commit 0c0e75a

Please sign in to comment.