You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the constructor does not respect the constant keyword and occupies storage slots unnecessarily.
contract C {
uint constant x;
constructor(uint x_) public {
x = x_;
}
function get() public view returns (uint) {
return x;
}
}
Here, the function get will sload x from the first storage slot. However x could have instead been inlined into the contract code, avoiding using up any slots and avoiding a relatively expensive sload. This would be important in contracts that use delegatecall and wish to avoid any runtime dependence on their own storage.
The text was updated successfully, but these errors were encountered:
Currently the constructor does not respect the
constant
keyword and occupies storage slots unnecessarily.Here, the function
get
will sloadx
from the first storage slot. Howeverx
could have instead been inlined into the contract code, avoiding using up any slots and avoiding a relatively expensive sload. This would be important in contracts that use delegatecall and wish to avoid any runtime dependence on their own storage.The text was updated successfully, but these errors were encountered: