Skip to content

Commit

Permalink
Merge pull request #5 from amiyagupta/string-concat-stringbuilder
Browse files Browse the repository at this point in the history
Use StringBuilder to reduce cost of concatenation
  • Loading branch information
pmeenan committed Mar 30, 2018
2 parents c8b887a + 05b58bb commit 4a7006e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Program.cs
Expand Up @@ -59,7 +59,7 @@ class Program
static TraceEventSession session;
static bool must_exit = false;
private static Mutex mutex = new Mutex();
static string events = "";
static StringBuilder events = new StringBuilder(2000000);
static string body_dir = "";
static Dictionary<string, CustomProvider> customProviders = new Dictionary<string, CustomProvider>();
static string customProvidersConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @".\customProviders.json");
Expand Down Expand Up @@ -158,7 +158,7 @@ static void Main(string[] args)
if (json.IndexOf("http://127.0.0.1:8888") == -1)
{
mutex.WaitOne();
events += json;
events.Append(json);
mutex.ReleaseMutex();
}
//Debug.WriteLine(json.Trim());
Expand Down Expand Up @@ -234,8 +234,8 @@ private static void ThreadProc()
mutex.WaitOne();
if (events.Length > 0)
{
buff = events;
events = "";
buff = events.ToString();
events.Clear();
}
mutex.ReleaseMutex();

Expand Down

0 comments on commit 4a7006e

Please sign in to comment.