perf: Use HashSet for O(1) secret masking lookups#1723
Merged
Conversation
Fixes #1539 Changed BuildSystemSecretMasker from List<string> to HashSet<string> for tracking already-masked secrets. This provides O(1) lookup instead of O(n), improving performance when many secrets need to be masked. Before: O(n*m) where n=existing secrets, m=new secrets After: O(m) - each new secret is O(1) lookup HashSet.Add() returns false if the item already exists, eliminating the need for a separate Contains() check. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Owner
Author
SummaryPerformance optimization that replaces List with HashSet for O(1) secret deduplication in BuildSystemSecretMasker. Critical IssuesNone found ✅ SuggestionsNone - this is a clean performance improvement with correct implementation. Verdict✅ APPROVE - No critical issues Analysis:
|
There was a problem hiding this comment.
Pull request overview
This PR optimizes the secret masking performance by replacing a List<string> with a HashSet<string> for tracking already-masked secrets, reducing lookup complexity from O(n) to O(1).
Key Changes:
- Changed
_alreadyMaskedSecretsfromList<string>toHashSet<string> - Leveraged
HashSet.Add()return value to eliminate duplicate checking logic - Removed LINQ
.Where()filter in favor of direct HashSet operations
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.
Summary
Fixes #1539
Changed
BuildSystemSecretMaskerfromList<string>toHashSet<string>for tracking already-masked secrets.Changes
List<string>withHashSet<string>for_alreadyMaskedSecretsHashSet.Add()return value to check if already exists (returns false if duplicate).Where()filter in favor of direct HashSet operationPerformance
Where n = existing secrets, m = new secrets
Test plan
🤖 Generated with Claude Code