Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: removeAt(index) in EnumerableSet #5025

Open
RyanRHall opened this issue Apr 23, 2024 · 0 comments
Open

Feature Request: removeAt(index) in EnumerableSet #5025

RyanRHall opened this issue Apr 23, 2024 · 0 comments

Comments

@RyanRHall
Copy link

馃 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant