Feature Request: removeAt(index) in EnumerableSet
RyanRHall opened this issue · 0 comments
RyanRHall commented
🧐 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