Skip to content

Commit 240a0e0

Browse files
committed
Move the obscure password regex in the Logger to a static field and make the regex compiled to hopefully shave off a few ms during logging.
1 parent 3f98794 commit 240a0e0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/GitVersionCore/Logger.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ namespace GitVersion
66

77
public static class Logger
88
{
9+
static readonly Regex ObscurePasswordRegex = new Regex("(https?://)(.+)(:.+@)", RegexOptions.Compiled);
910
static string indent = string.Empty;
1011

1112
public static Action<string> WriteInfo { get; private set; }
1213
public static Action<string> WriteWarning { get; private set; }
1314
public static Action<string> WriteError { get; private set; }
1415

16+
1517
static Logger()
1618
{
1719
Reset();
@@ -33,8 +35,7 @@ static Action<string> ObscurePassword(Action<string> info)
3335
{
3436
Action<string> logAction = s =>
3537
{
36-
var rgx = new Regex("(https?://)(.+)(:.+@)");
37-
s = rgx.Replace(s, "$1$2:*******@");
38+
s = ObscurePasswordRegex.Replace(s, "$1$2:*******@");
3839
info(s);
3940
};
4041
return logAction;

0 commit comments

Comments
 (0)