code-423n4 / 2021-10-tracer-findings

0 stars 0 forks source link

Cache array length in for loops can save gas #28

Closed code423n4 closed 3 years ago

code423n4 commented 3 years ago

Handle

WatchPug

Vulnerability details

Reading array length at each iteration of the loop takes 6 gas (3 for mload and 3 to place memory_offset) in the stack.

Caching the array length in the stack saves around 3 gas per iteration.

Instances include:

CalabashSquash commented 3 years ago

Duplicate of https://github.com/code-423n4/2021-10-tracer-findings/issues/1

GalloDaSballo commented 3 years ago

Duplicate of #1

Will set to invalid or accept based on Sponsor Feedback

GalloDaSballo commented 3 years ago

Marking as invalid as per above