solidity
solidity copied to clipboard
Do not duplicate runtime code in constructor
trafficstars
The Solidity compiler currently generates constructor code so that the deployed code is fully independent. If a function is used both in the constructor and the deployed code, it will be included twice. We could consider to use the some code for both constructor an deployed code, especially if the constructor code is large. In order to do this, the first thing the code needs to do is detect if it is currently running in "constructor mode" or not. This should be possible by using extcodesize(address())), but it is rather costly. Another way would be to use a fixed immutable flag to fulfil this purpose.