Compile the regex that extract categories for colourization just once rather than on every single log.
Compiling every time is unnecessary since Regex is thread-safe.bullet-2.82
parent
fbcb76383d
commit
f55e153636
|
@ -46,6 +46,11 @@ namespace OpenSim.Framework.Console
|
||||||
// private readonly object m_syncRoot = new object();
|
// private readonly object m_syncRoot = new object();
|
||||||
private const string LOGLEVEL_NONE = "(none)";
|
private const string LOGLEVEL_NONE = "(none)";
|
||||||
|
|
||||||
|
// Used to extract categories for colourization.
|
||||||
|
private Regex m_categoryRegex
|
||||||
|
= new Regex(
|
||||||
|
@"^(?<Front>.*?)\[(?<Category>[^\]]+)\]:?(?<End>.*)", RegexOptions.Singleline | RegexOptions.Compiled);
|
||||||
|
|
||||||
private int m_cursorYPosition = -1;
|
private int m_cursorYPosition = -1;
|
||||||
private int m_cursorXPosition = 0;
|
private int m_cursorXPosition = 0;
|
||||||
private StringBuilder m_commandLine = new StringBuilder();
|
private StringBuilder m_commandLine = new StringBuilder();
|
||||||
|
@ -281,10 +286,7 @@ namespace OpenSim.Framework.Console
|
||||||
|
|
||||||
if (level != LOGLEVEL_NONE)
|
if (level != LOGLEVEL_NONE)
|
||||||
{
|
{
|
||||||
string regex = @"^(?<Front>.*?)\[(?<Category>[^\]]+)\]:?(?<End>.*)";
|
MatchCollection matches = m_categoryRegex.Matches(text);
|
||||||
|
|
||||||
Regex RE = new Regex(regex, RegexOptions.Singleline);
|
|
||||||
MatchCollection matches = RE.Matches(text);
|
|
||||||
|
|
||||||
if (matches.Count == 1)
|
if (matches.Count == 1)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue