You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On the one hand, this function looks as if it was written with gas-optimization in mind.
On the other hand, it looks like the optimization was rather poorly applied.
First off all, instead of checking the value of isCalldata on every iteration, it makes since to split this function into two functions, one for the case of isCalldata = 1 and another for all other cases.
Alternatively, you could run that check outside the loop, and then implement two separate loops (one for each case).
Second, the logic around the calculation of _count seems like something which can be done once instead of on every iteration.
You can do this by splitting the loop into two parts:
A loop over all 256-length chunks
A final iteration for the last chunk (if larger than 0)
On the one hand, this function looks as if it was written with gas-optimization in mind.
On the other hand, it looks like the optimization was rather poorly applied.
First off all, instead of checking the value of
isCalldata
on every iteration, it makes since to split this function into two functions, one for the case ofisCalldata = 1
and another for all other cases.Alternatively, you could run that check outside the loop, and then implement two separate loops (one for each case).
Second, the logic around the calculation of
_count
seems like something which can be done once instead of on every iteration.You can do this by splitting the loop into two parts:
For example:
The text was updated successfully, but these errors were encountered: