[smuxi: 110/179] MessageBuilder: refactor foreach loop into Linq query



commit d61989652abef213e2e473ec211d53a1e84bf2d4
Author: Andres G. Aragoneses <knocte gmail com>
Date:   Mon Oct 31 23:54:09 2016 +0800

    MessageBuilder: refactor foreach loop into Linq query

 src/Engine/Messages/MessageBuilder.cs |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
---
diff --git a/src/Engine/Messages/MessageBuilder.cs b/src/Engine/Messages/MessageBuilder.cs
index 8627375..a2bd456 100644
--- a/src/Engine/Messages/MessageBuilder.cs
+++ b/src/Engine/Messages/MessageBuilder.cs
@@ -892,12 +892,9 @@ namespace Smuxi.Engine
             
             int lastindex = 0;
             do {
-                var groupValues = new string[match.Groups.Count];
-                int i = 0;
-                foreach (Group @group in match.Groups) {
-                    groupValues[i++] = @group.Value;
-                }
-                
+                var groupValues = match.Groups.Cast<Group>()
+                    .Select(g => g.Value).ToArray();
+
                 string url;
                 if (String.IsNullOrEmpty(pattern.LinkFormat)) {
                     url = match.Value;


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