Permalink
Browse files

Don't use StringBuilder or foreach in this hot code pahth.

  • Loading branch information...
1 parent 5fb02ed commit 934e581460e4850f3ee2b58b72183eceb0e223d1 @davidfowl davidfowl committed Jul 3, 2012
Showing with 9 additions and 11 deletions.
  1. +9 −11 SignalR/MessageBus/MessageBus.cs
@@ -475,23 +475,21 @@ internal class Cursor
public Topic Topic { get; set; }
- public static string MakeCursor(IEnumerable<Cursor> cursors)
+ public static string MakeCursor(IList<Cursor> cursors)
{
- var sb = new StringBuilder();
- bool first = true;
- foreach (var c in cursors)
+ var result = "";
+ for (int i = 0; i < cursors.Count; i++)
{
- if (!first)
+ if (i > 0)
{
- sb.Append('|');
+ result += '|';
}
- sb.Append(Escape(c.Key));
- sb.Append(',');
- sb.Append(c.Id);
- first = false;
+ result += Escape(cursors[i].Key);
+ result += ',';
+ result += cursors[i].Id;
}
- return sb.ToString();
+ return result;
}
private static string Escape(string value)

0 comments on commit 934e581

Please sign in to comment.