diff options
author | Justin Clark-Casey (justincc) | 2014-05-23 21:09:48 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-05-23 21:09:48 +0100 |
commit | f55e15363665ac885b51fa549c9c1566e9ea0cc6 (patch) | |
tree | baafa80c4d9c3ce72ef9d6ddac01b84f3cb63712 /OpenSim | |
parent | Allow console output to be multiline by making colourization regex RegexOptio... (diff) | |
download | opensim-SC_OLD-f55e15363665ac885b51fa549c9c1566e9ea0cc6.zip opensim-SC_OLD-f55e15363665ac885b51fa549c9c1566e9ea0cc6.tar.gz opensim-SC_OLD-f55e15363665ac885b51fa549c9c1566e9ea0cc6.tar.bz2 opensim-SC_OLD-f55e15363665ac885b51fa549c9c1566e9ea0cc6.tar.xz |
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.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Console/LocalConsole.cs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index b17b8e0..260a86f 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs | |||
@@ -46,6 +46,11 @@ namespace OpenSim.Framework.Console | |||
46 | // private readonly object m_syncRoot = new object(); | 46 | // private readonly object m_syncRoot = new object(); |
47 | private const string LOGLEVEL_NONE = "(none)"; | 47 | private const string LOGLEVEL_NONE = "(none)"; |
48 | 48 | ||
49 | // Used to extract categories for colourization. | ||
50 | private Regex m_categoryRegex | ||
51 | = new Regex( | ||
52 | @"^(?<Front>.*?)\[(?<Category>[^\]]+)\]:?(?<End>.*)", RegexOptions.Singleline | RegexOptions.Compiled); | ||
53 | |||
49 | private int m_cursorYPosition = -1; | 54 | private int m_cursorYPosition = -1; |
50 | private int m_cursorXPosition = 0; | 55 | private int m_cursorXPosition = 0; |
51 | private StringBuilder m_commandLine = new StringBuilder(); | 56 | private StringBuilder m_commandLine = new StringBuilder(); |
@@ -280,11 +285,8 @@ namespace OpenSim.Framework.Console | |||
280 | string outText = text; | 285 | string outText = text; |
281 | 286 | ||
282 | if (level != LOGLEVEL_NONE) | 287 | if (level != LOGLEVEL_NONE) |
283 | { | 288 | { |
284 | string regex = @"^(?<Front>.*?)\[(?<Category>[^\]]+)\]:?(?<End>.*)"; | 289 | MatchCollection matches = m_categoryRegex.Matches(text); |
285 | |||
286 | Regex RE = new Regex(regex, RegexOptions.Singleline); | ||
287 | MatchCollection matches = RE.Matches(text); | ||
288 | 290 | ||
289 | if (matches.Count == 1) | 291 | if (matches.Count == 1) |
290 | { | 292 | { |