If you've found this page via one of my old gas reports, please see this link
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13; // optimize 200
/**
* @title SetVsDefault
* @author IllIllI
*/
contract SetVsDefault {
function test(uint256 x) external pure returns(uint256) {
for (uint256 i = 0; i < 10; ++i) {
x += 2;
}
return x;
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13; // optimize 200
/**
* @title SetVsDefault
* @author IllIllI
*/
contract SetVsDefault {
function test(uint256 x) external pure returns(uint256) {
for (uint256 i; i < 10; ++i) {
x += 2;
}
return x;
}
}
diff --git a/SetVsDefault_s.sol b/SetVsDefault_d.sol
index 7594b22..541d4cd 100644
--- a/SetVsDefault_s.sol
+++ b/SetVsDefault_d.sol
@@ -7,7 +7,7 @@ pragma solidity 0.8.13; // optimize 200
*/
contract SetVsDefault {
function test(uint256 x) external pure returns(uint256) {
- for (uint256 i = 0; i < 10; ++i) {
+ for (uint256 i; i < 10; ++i) {
x += 2;
}
return x;
$ solc SetVsDefault_s.sol --bin --optimize --optimize-runs 200 | egrep "^60[0-9]+"
608060405234801561001057600080fd5b50610108806100206000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806329e99f0714602d575b600080fd5b603c60383660046079565b604e565b60405190815260200160405180910390f35b6000805b600a811015607257606360028460a7565b9250606c8160bc565b90506052565b5090919050565b600060208284031215608a57600080fd5b5035919050565b634e487b7160e01b600052601160045260246000fd5b6000821982111560b75760b76091565b500190565b60006001820160cb5760cb6091565b506001019056fea26469706673582212203fbb20008125805e3f41b00bbd93860ac88b5224428d36ee9f6ba7a214649ee164736f6c634300080d0033
$ solc SetVsDefault_d.sol --bin --optimize --optimize-runs 200 | egrep "^60[0-9]+"
608060405234801561001057600080fd5b50610108806100206000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806329e99f0714602d575b600080fd5b603c60383660046079565b604e565b60405190815260200160405180910390f35b6000805b600a811015607257606360028460a7565b9250606c8160bc565b90506052565b5090919050565b600060208284031215608a57600080fd5b5035919050565b634e487b7160e01b600052601160045260246000fd5b6000821982111560b75760b76091565b500190565b60006001820160cb5760cb6091565b506001019056fea2646970667358221220420fe424b02a4807f8f2f77e369fe5a3f85008d62b7cc05b8d3ee79b9e55334464736f6c634300080d0033
no bytecode differences
noob question. How to get that beautiful output?