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++)
Use ++ i instead of i++
++ i is one less opcode than i++ therefore take less gas.
I recommend to replace all of them especially those in the loop.
Cancele the atuo check
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.
[G001]: Cache Array Length Outside of Loop
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++)
Use ++ i instead of i++
++ i is one less opcode than i++ therefore take less gas. I recommend to replace all of them especially those in the loop.
Cancele the atuo check
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.