// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0; // optimize 200
/**
* @title AbiStringsSplitCommasVsNone
* @author IllIllI
*/
contract AbiStringsSplitCommasVsNone {
function test() external pure returns (bytes memory) {
return abi.encodePacked("aaa", "bbb", "ccc");
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0; // optimize 200
/**
* @title AbiStringsSplitCommasVsNone
* @author IllIllI
*/
contract AbiStringsSplitCommasVsNone {
function test() external pure returns (bytes memory) {
return abi.encodePacked("aaa" "bbb" "ccc");
}
}
diff --git a/AbiStringsSplitCommasVsNone_c.sol b/AbiStringsSplitCommasVsNone_n.sol
index 84dd713..aad1c72 100644
--- a/AbiStringsSplitCommasVsNone_c.sol
+++ b/AbiStringsSplitCommasVsNone_n.sol
@@ -7,7 +7,7 @@ pragma solidity ^0.8.0; // optimize 200
*/
contract AbiStringsSplitCommasVsNone {
function test() external pure returns (bytes memory) {
- return abi.encodePacked("aaa", "bbb", "ccc");
+ return abi.encodePacked("aaa" "bbb" "ccc");
}
}
$ solc AbiStringsSplitCommasVsNone_c.sol --bin --optimize --optimize-runs 200 | egrep "^60[0-9]+"
608060405234801561001057600080fd5b50610117806100206000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063f8a8fd6d14602d575b600080fd5b60336047565b604051603e91906091565b60405180910390f35b6060604051602001605690606a565b604051602081830303815290604052905090565b6261616160e81b81526231313160e91b60038201526263636360e81b600682015260090190565b6000602080835283518082850152825b8181101560bb5785810183015185820160400152820160a1565b8181111560cb5783604083870101525b50601f01601f191692909201604001939250505056fea2646970667358221220e2d628d3a2717cf1df401a791a275eb12e6b297465549001a8deeacb380a100164736f6c63430008000033
$ solc AbiStringsSplitCommasVsNone_n.sol --bin --optimize --optimize-runs 200 | egrep "^60[0-9]+"
608060405234801561001057600080fd5b50610105806100206000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063f8a8fd6d14602d575b600080fd5b60336047565b604051603e9190607f565b60405180910390f35b6060604051602001605690606a565b604051602081830303815290604052905090565b6861616162626263636360b81b815260090190565b6000602080835283518082850152825b8181101560a957858101830151858201604001528201608f565b8181111560b95783604083870101525b50601f01601f191692909201604001939250505056fea26469706673582212205a00d718713a663b2d4eadfdf4406666c45000f18b8be7ec19421326ba6d423d64736f6c63430008000033
PC.Orig | Operation.Orig | Gas.Orig | PC.New | Operation.New | Gas.New |
---|---|---|---|---|---|
137(0x89) | JUMP(0x56) | 8 | 137(0x89) | JUMP(0x56) | 8 |
138(0x8a) | JUMPDEST(0x5b)@0x8a | 1 | 138(0x8a) | JUMPDEST(0x5b)@0x8a | 1 |
139(0x8b) | PUSH9(0x68) ["0x61","0x61",... | 3 | |||
139(0x8b) | PUSH3(0x62) ["0x61","0x61",... | 3 | |||
143(0x8f) | PUSH1(0x60) ["0xe8"] | 3 | 149(0x95) | PUSH1(0x60) ["0xb8"] | 3 |
145(0x91) | SHL(0x1b) | 3 | 151(0x97) | SHL(0x1b) | 3 |
146(0x92) | DUP2(0x81) | 3 | 152(0x98) | DUP2(0x81) | 3 |
147(0x93) | MSTORE(0x52) | 3 | 153(0x99) | MSTORE(0x52) | 3 |
148(0x94) | PUSH3(0x62) ["0x31","0x31",... | 3 | |||
152(0x98) | PUSH1(0x60) ["0xe9"] | 3 | |||
154(0x9a) | SHL(0x1b) | 3 | |||
155(0x9b) | PUSH1(0x60) ["0x03"] | 3 | |||
157(0x9d) | DUP3(0x82) | 3 | |||
158(0x9e) | ADD(0x1) | 3 | |||
159(0x9f) | MSTORE(0x52) | 3 | |||
160(0xa0) | PUSH3(0x62) ["0x63","0x63",... | 3 | |||
164(0xa4) | PUSH1(0x60) ["0xe8"] | 3 | |||
166(0xa6) | SHL(0x1b) | 3 | |||
167(0xa7) | PUSH1(0x60) ["0x06"] | 3 | |||
169(0xa9) | DUP3(0x82) | 3 | |||
170(0xaa) | ADD(0x1) | 3 | |||
171(0xab) | MSTORE(0x52) | 3 | |||
172(0xac) | PUSH1(0x60) ["0x09"] | 3 | 154(0x9a) | PUSH1(0x60) ["0x09"] | 3 |
174(0xae) | ADD(0x1) | 3 | 156(0x9c) | ADD(0x1) | 3 |
175(0xaf) | SWAP1(0x90) | 3 | 157(0x9d) | SWAP1(0x90) | 3 |
176(0xb0) | JUMP(0x56) | 8 | 158(0x9e) | JUMP(0x56) | 8 |
Total.Orig: | 83 | Total.New: | 41 |
The change provides a savings of 42 gas