Skip to content

Commit 7595d92

Browse files
committed
Slight optimization: Avoid unecessary lookup before setting key/value
1 parent 455c181 commit 7595d92

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

src/NodeServices/TraceSupport.cs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Runtime.Serialization;
43

54
namespace DynamoServices
65
{
@@ -70,15 +69,9 @@ internal static void ClearAllKnownTLSKeys()
7069
/// <returns></returns>
7170
public static string GetTraceData(string key)
7271
{
73-
string data;
74-
if (!LocalStorageSlot.TryGetValue(key, out data))
75-
{
76-
return null;
77-
}
78-
else
79-
{
72+
if (LocalStorageSlot.TryGetValue(key, out string data))
8073
return data;
81-
}
74+
return null;
8275
}
8376

8477
/// <summary>
@@ -88,14 +81,7 @@ public static string GetTraceData(string key)
8881
/// <param name="value"></param>
8982
public static void SetTraceData(string key, string value)
9083
{
91-
if (LocalStorageSlot.ContainsKey(key))
92-
{
93-
LocalStorageSlot[key] = value;
94-
}
95-
else
96-
{
97-
LocalStorageSlot.Add(key, value);
98-
}
84+
LocalStorageSlot[key] = value;
9985
}
10086
}
10187
}

0 commit comments

Comments
 (0)