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
I did a few tests around this to see what is the most gas optimal way to calculate. Here are the results:
Option tested
Gas cost of mint function
push tokens then get index with: tokens.length.sub(1)
158760
push tokens then get index with: tokens.length - 1
158665
get lenght as a result from push then calculate index as -1 from that lenght
158465
get lenght as a result from push then calculate index as .sub(1) from that lenght
158560
first get lenght then push token then just set the lenght
158672
As you can see the suggested way is indeed the most GAS efficient. The subtraction is done after push so there is no need to use safemath library for the subtraction.
As such we will do this change everywhere where it is applicable. PR coming soon.
@mg6maciej suggested: #109 (review)
If we do this, we should do it everywhere where this is applicable.
The text was updated successfully, but these errors were encountered: