Closed ParsaAminpour closed 2 months ago
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
I calculated mask opcode by opcode and realized that calculating mask in this way is slightly gas-efficient. Based on these test cases
The actual functions' code
```solidity function mask1(uint8 bitPos) external pure returns(uint256 mask) { mask = (1 << bitPos) - 1 + (1 << bitPos); } function mask2(uint8 bitPos) external pure returns(uint256 mask) { mask = (1 << (bitPos+1)) - 1; } ```And the result is (via foundry):
As you can see, there is a small difference in gas consumption between these two functions.