Skip to content

Commit 2cf1ead

Browse files
thomhurstclaude
andcommitted
perf: Remove redundant Contains check in SecretObfuscator
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 7412b8d commit 2cf1ead

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)