Uniswap / v2-periphery

🎚 Peripheral smart contracts for interacting with Uniswap V2
https://uniswap.org/docs
GNU General Public License v3.0
1.14k stars 1.69k forks source link

change memory to calldata to save gas #158

Closed molly-ting closed 1 year ago

molly-ting commented 1 year ago

Changing the data location of function parameters from memory to calldata can save much gas. In the following example, test4 saves about 955 units of gas.

    function test3(uint256[] memory amounts) public {
        uint256 amount = amounts[0];
    }

    function test4(uint256[] calldata amounts) public {
        uint256 amount = amounts[0];
    }
molly-ting commented 1 year ago

could someone take a look? I think this could save some gas.

stale[bot] commented 1 year 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.