-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gas Optimizations #67
Comments
"You can remove it to save some gas, or leave it if it was intended for future use with other factories" (Acknowledged)Consider using EnumerableSet to store operators (Acknowledged)"Could just use msg.sender and do not call an owner() function here" (Confirmed)
|
My personal judgments:
|
Also, #66 has the additional issue: |
Now, here is the methodology I used for calculating a score for each gas report. I first assigned each submission to be either small-optimization (1 point), medium-optimization (5 points) or large-optimization (10 points), depending on how useful the optimization is. The score of a gas report is the sum of these points, divided by the maximum number of points achieved by a gas report. This maximum number was 10 points, achieved by #67. The number of points achieved by this report is 10 points. |
function transfer in NestedReserve is never used and can only be called by the factory (onlyFactory), so consider removing it because I think the factory uses a withdraw function from the Reserve.
Currently never used:
function setReserve onlyFactory
You can remove it to save some gas, or leave it if it was intended for future use with other factories.
functions that add or remove operators or shareholders iterate over the whole array, so you can consider using EnumerableSet to store them:
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/structs/EnumerableSet.sol
Could just use msg.sender and do not call an owner() function here:
because processInputOrders and processInputAndOutputOrders both call _processInputOrders, the logic from _checkMsgValue could be moved to _processInputOrders. function create then can be refactored to re-use _processInputOrders. I see 2 discrepancies here: _fromReserve is always false when _submitInOrders is called from create (could be solved if _processInputOrders takes extra parameter), and _processInputOrders has this extra line:
but this could be solved if you first mint the NFT and then invoke _processInputOrders from create.
I think it could just substitute these links by first fetching all the tokens, and then calculating the length itself instead of making 2 external calls for pretty much the same data.
The text was updated successfully, but these errors were encountered: