Closed Arkay92 closed 1 year ago
Before:
·-----------------------------------|-------------|---------------·
| Deployments · · % of limit │
····································|·············|················
| ERC721AQueryableMock · 1460247 · 4.9 % │
····································|·············|················
| ERC721AQueryableStartTokenIdMock · 1528641 · 5.1 % │
·-----------------------------------|-------------|---------------·
After:
·-----------------------------------|-------------|---------------·
| Deployments · · % of limit │
····································|·············|················
| ERC721AQueryableMock · 1447033 · 4.8 % │
····································|·············|················
| ERC721AQueryableStartTokenIdMock · 1517582 · 5.1 % │
·-----------------------------------|-------------|---------------·
Could save more if we use assembly to directly write to the memory arrays, cuz Solidity adds out-of-bounds checks, which is redundant in this case.
@cygaar
After the changes, the deployment gas is 1356357.
This is about 100k gas less, which is around 500 bytes saved. Before, the Queryable extension alone adds 2000 bytes. With these changes, it adds 1500 bytes.
Can be useful for people trying to avoid hitting the max contract size.
Right now, I think Queryable should be optimized for smaller bytecode size. Runtime gas is second priority.
https://github.com/Vectorized/ERC721A/blob/bytecodeopt/contracts/extensions/ERC721AQueryable.sol