Skip to content

Optimize FeatureFlags.IsEnabled #10883

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

Closed
kshyju opened this issue Feb 26, 2025 · 0 comments · Fixed by #11076
Closed

Optimize FeatureFlags.IsEnabled #10883

kshyju opened this issue Feb 26, 2025 · 0 comments · Fixed by #11076
Assignees
Labels

Comments

@kshyju
Copy link
Member

kshyju commented Feb 26, 2025

The FeatureFlags.IsEnabled method currently uses string.Split, which results in a string array allocation. Instead, we can optimize this by using ReadOnlySpan<char> to check if the requested feature name is present, avoiding the extra allocation.

string[] flags = featureFlags.Split(',');
return flags.Contains(name, StringComparer.OrdinalIgnoreCase);

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

Successfully merging a pull request may close this issue.

1 participant