[smuxi/experiments/certfp: 51/55] Engine: re-use regex instance in MessageModel



commit 92a0530ded96b50c678ca6ae120c55762eccf0a2
Author: Mirco Bauer <meebey meebey net>
Date:   Sun Jan 12 08:08:02 2014 +0100

    Engine: re-use regex instance in MessageModel

 src/Engine/Messages/MessageModel.cs |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/src/Engine/Messages/MessageModel.cs b/src/Engine/Messages/MessageModel.cs
index 081c89d..4fb360a 100644
--- a/src/Engine/Messages/MessageModel.cs
+++ b/src/Engine/Messages/MessageModel.cs
@@ -33,6 +33,7 @@ namespace Smuxi.Engine
     [Serializable]
     public class MessageModel : ISerializable
     {
+        static readonly Regex NickRegex = new Regex("^<([^ ]+)> ");
         private DateTime                f_TimeStamp;
         private IList<MessagePartModel> f_MessageParts;
         private MessageType             f_MessageType;
@@ -257,7 +258,7 @@ namespace Smuxi.Engine
             // meesage itself
             // TODO: extend MessageModel with Origin property
             var msgText = ToString();
-            var match = Regex.Match(msgText, "^<([^ ]+)>");
+            var match = NickRegex.Match(msgText);
             if (match.Success && match.Groups.Count >= 2) {
                 return match.Groups[1].Value;
             }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]