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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to enumerate over the List to prevent allocation every time List is called #494

Closed
akarboush opened this issue Feb 20, 2024 · 2 comments · Fixed by #497
Closed

Comments

@akarboush
Copy link
Contributor

Introduce a way to enumerate the enum values without unnecessary memory allocation. This will be useful especially for scenarios requiring frequent iteration.

I'd happily do a PR if that's okay.
Something like this:

public static IEnumerable<TEnum> EnumerateList() => _fromName.Value.Values;
@ardalis
Copy link
Owner

ardalis commented Feb 21, 2024

Yeah, that would be a great addition. PR away!

@akarboush
Copy link
Contributor Author

closed by #497

akarboush added a commit to akarboush/SmartEnum that referenced this issue Apr 28, 2024
ardalis added a commit that referenced this issue Apr 28, 2024
#497)

* Add EnumerateList Method (#494)

* Revert "Add EnumerateList Method (#494)"

This reverts commit 30d46af.

* Prevent allocation when calling List

---------

Co-authored-by: Steve Smith <steve@kentsmiths.com>
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

Successfully merging a pull request may close this issue.

2 participants