ava-labs / teleporter-token-bridge

Token bridging cross-chain built on top of Teleporter
Other
10 stars 5 forks source link

calculateNumWords gas optimization #97

Closed michaelkaplan13 closed 1 month ago

michaelkaplan13 commented 1 month ago

Why this should be merged

Thanks to @bernard-avalabs for both of these suggestions here.

How this works

Uses bit shifting rather than division and mod.

How this was tested

Existing unit tests with forge test --gas-report

| Function Name                          | min             | avg   | median | max    | # calls |
| calculateNumWords (pre-update)         | 557             | 594   | 622    | 622    | 7       |
| calculateNumWords (post-update)        | 496             | 496   | 496    | 496    | 7       |

How is this documented

N/A

openzeppelin-code[bot] commented 1 month ago

calculateNumWords gas optimization

Generated at commit: 23ae996b23d7f9a01a4a10ca70bce42764ad1764

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
1
0
0
2
13
16
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector