Skip to content

Commit 8dcf7ec

Browse files
thomhurstclaude
andauthored
perf: Remove redundant Contains check in SecretObfuscator (#1715)
The Contains check was redundant because StringBuilder.Replace already handles the case where the search string doesn't exist. Additionally, the check was done on the original input string while Replace operates on the StringBuilder, creating an inconsistency after the first replacement. Fixes #1549 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f05c924 commit 8dcf7ec

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

src/ModularPipelines/Engine/SecretObfuscator.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ public string Obfuscate(string? input, object? optionsObject)
2929

3030
foreach (var secret in _secretProvider.Secrets.Concat(secretsFromExtraObject))
3131
{
32-
if (input.Contains(secret))
33-
{
34-
stringBuilder.Replace(secret, LoggingConstants.SecretMask);
35-
}
32+
stringBuilder.Replace(secret, LoggingConstants.SecretMask);
3633
}
3734

3835
return stringBuilder.ToString();

0 commit comments

Comments
 (0)