[Repo Assist] improve: use FrozenSet for ExecEnvSanitizer blocked-names lookup#194
Merged
shanselman merged 1 commit intomasterfrom Apr 23, 2026
Conversation
_blockedNames is initialised once at startup and never mutated. FrozenSet gives lower constant-factor O(1) Contains() compared to HashSet, and matches the pattern already used throughout the codebase (ChannelHealth.s_healthyStatuses / s_intermediateStatuses in Models.cs, NotificationCategorizer.ChannelMap / IntentMap, etc.). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated PR from Repo Assist.
Summary
Upgrades
_blockedNamesinExecEnvSanitizerfromHashSet<string>toFrozenSet<string>.What changed
Why
_blockedNamesis written once at class initialisation and never mutated.FrozenSet<T>is specifically designed for this pattern — it provides O(1)Containswith lower constant-factor overhead thanHashSetbecause it stores no mutation infrastructure.This matches the established pattern already used throughout the codebase:
FrozenSet<string>ChannelHealth.s_healthyStatuses/s_intermediateStatuses(Models.cs)FrozenDictionary<string, ...>NotificationCategorizer.ChannelMap/IntentMap/CategoryTitlesFrozenDictionary<string, string>ChannelHealth.s_statusLabels(Models.cs)IsBlocked()is called on every environment-variable key that passes throughsystem.run, making this a meaningful hot-path improvement.Test Status
dotnet build— succeeded, 0 errors, 0 warningsdotnet test OpenClaw.Shared.Tests— passed (exit 0)dotnet test OpenClaw.Tray.Tests— passed (exit 0)