-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ColoredConsoleTarget performance improvements. #1112
Changes from 4 commits
4b88a21
79375af
e2d3a17
a564528
6b89e23
562eb6b
756f2a8
f8e4a6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,20 @@ public ConsoleWordHighlightingRule(string text, ConsoleOutputColor foregroundCol | |
[DefaultValue(false)] | ||
public bool IgnoreCase { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the foreground color. | ||
/// </summary> | ||
/// <docgen category='Formatting Options' order='10' /> | ||
[DefaultValue("NoChange")] | ||
public ConsoleOutputColor ForegroundColor { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the background color. | ||
/// </summary> | ||
/// <docgen category='Formatting Options' order='10' /> | ||
[DefaultValue("NoChange")] | ||
public ConsoleOutputColor BackgroundColor { get; set; } | ||
|
||
/// <summary> | ||
/// Gets the compiled regular expression that matches either Text or Regex property. | ||
/// </summary> | ||
|
@@ -116,7 +130,7 @@ public Regex CompiledRegex | |
} | ||
} | ||
|
||
RegexOptions regexOptions = RegexOptions.Compiled; | ||
RegexOptions regexOptions = RegexOptions.None; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a performance boost according to the test? Because we also won't use regex caching, (static regex), which is maybe not that nice. Also I'm bit in doubt with this change due to the name of the property. What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change does not yield a noticeable change in performance. The reason I changed this was due to a previous comment referring to the MSDN documentation stating that the I personally do not think this makes much of a difference. I'll change it back if you want. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should pick one of the two: use caching, or use compied. As this one isn't 1 of them, I prefer a revert (also because of the name). |
||
if (this.IgnoreCase) | ||
{ | ||
regexOptions |= RegexOptions.IgnoreCase; | ||
|
@@ -129,21 +143,7 @@ public Regex CompiledRegex | |
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the foreground color. | ||
/// </summary> | ||
/// <docgen category='Formatting Options' order='10' /> | ||
[DefaultValue("NoChange")] | ||
public ConsoleOutputColor ForegroundColor { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the background color. | ||
/// </summary> | ||
/// <docgen category='Formatting Options' order='10' /> | ||
[DefaultValue("NoChange")] | ||
public ConsoleOutputColor BackgroundColor { get; set; } | ||
|
||
internal string MatchEvaluator(Match m) | ||
private string MatchEvaluator(Match m) | ||
{ | ||
StringBuilder result = new StringBuilder(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we extract this to a method? (DRY)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.