Platform: Code4rena
Start Date: 10/05/2022
Pot Size: $50,000 USDC
Total HM: 13
Participants: 100
Period: 5 days
Judge: HardlyDifficult
Total Solo HM: 1
Id: 122
League: ETH
Rank: 92/100
Findings: 1
Award: $30.09
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0v3rf10w, 0x1f8b, 0x4non, 0xDjango, 0xNazgul, 0xf15ers, 0xkatana, 0xsanson, Bludya, BowTiedWardens, CertoraInc, Cityscape, DavidGialdi, FSchmoede, Fitraldys, Funen, Hawkeye, Kenshin, MadWookie, MaratCerby, MiloTruck, Picodes, RagePit, Tadashi, TerrierLover, TomFrenchBlockchain, VAD37, WatchPug, Waze, _Adam, antonttc, bobirichman, catchup, defsec, delfin454000, djxploit, ellahi, fatherOfBlocks, gzeon, hake, hansfriese, hickuphh3, horsefacts, ignacio, joestakey, jonatascm, mics, minhquanym, oyc_109, pmerkleplant, rfa, robee, rotcivegaf, samruna, shung, sikorico, simon135, z3s
30.0895 USDC - $30.09
Instead of calculate the length in each iteration you can save the length in the variable to save gas.
for example you did it in:
lline 244 :
for (uint256 i = 0; i < data.length; i++)
I recommend to do:
**_length = data.length
for (uint256 i = 0; i < _length; i++)
**
++ i is one less opcode than i++ therefore take less gas. I recommend to replace all of them especially those in the loop.
from version 8+ the compilers add auto-tests to check over flow and underflow every time a mathematical operation is performed.
I would therefore recommend changing the loops
for (uint256 i;i < len;) { unchecked{++i;} } but it will make the loops less readable.