20,000 USDC
View results
Submission Details
Severity: gas
Valid

Using `x >> constant(uint)` with the right shift operator is a more gas-efficient

Summary

Vulnerability Details

<x> / 2 is the same as <x> >> 1. While the compiler uses the SHR opcode to accomplish both,
the version that uses division incurs an overhead of 20 gas
due to JUMPs to and from a compiler utility function that introduces checks which can
be avoided by using unchecked {} around the division by two

There are 6 instances of this issue:

Impact

Tools Used

Recommendations

Using bit shifting (>> operator) replace division divided by constant.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.