Skip to content

Commit 42783c0

Browse files
committed
Use TryAdd()
1 parent d84088c commit 42783c0

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/Files.Shared/Extensions/LinqExtensions.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static class LinqExtensions
3333
if (!dictionary.ContainsKey(key))
3434
{
3535
if (defaultValue is TValue value)
36-
dictionary.Add(key, value);
36+
dictionary.TryAdd(key, value);
3737

3838
return defaultValue;
3939
}
@@ -53,16 +53,8 @@ public static class LinqExtensions
5353
{
5454
var defaultValue = defaultValueFunc();
5555
if (defaultValue is Task<TValue?> value)
56-
{
57-
if (dictionary is ConcurrentDictionary<TKey, Task<TValue?>> cDict)
58-
{
59-
cDict.TryAdd(key, value);
60-
}
61-
else
62-
{
63-
dictionary.Add(key, value);
64-
}
65-
}
56+
dictionary.TryAdd(key, value);
57+
6658
return defaultValue;
6759
}
6860
return dictionary[key];

0 commit comments

Comments
 (0)