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
馃 Motivation
I find that I write this line somewhat often when working with EnumerableSet:
mySet.remove(mySet.at(index));
This is a bit clunky and not gas-optimized.
Doing the above in order to remove an item at a specific position adds some additional, unnecessary gas overhead because (1) we are forced to read the value from storage in order to call remove() and (2) the first thing the remove() function does is read the value's index from storage, (which we already know). A small optimization would be to add a function removeAt(index) that avoids these storage reads all together.
馃摑 Details
Add a function, removeAt(uint256 index) to the EnumerableSet library that removes an item at a specific index
The text was updated successfully, but these errors were encountered:
馃 Motivation
I find that I write this line somewhat often when working with EnumerableSet:
This is a bit clunky and not gas-optimized.
Doing the above in order to remove an item at a specific position adds some additional, unnecessary gas overhead because (1) we are forced to read the value from storage in order to call
remove()
and (2) the first thing theremove()
function does is read the value's index from storage, (which we already know). A small optimization would be to add a functionremoveAt(index)
that avoids these storage reads all together.馃摑 Details
Add a function,
removeAt(uint256 index)
to theEnumerableSet
library that removes an item at a specific indexThe text was updated successfully, but these errors were encountered: