Skip to content
This repository has been archived by the owner on Sep 5, 2019. It is now read-only.

Commit

Permalink
Solved sonar code smell (Merged if statements), removed System.Collec…
Browse files Browse the repository at this point in the history
…tions.Immutable and implemented promise state cleanup (#24)
  • Loading branch information
rstaib authored Aug 30, 2018
1 parent 7010e74 commit 171f686
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/Benchmark.Tests/Benchmark.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.11.1" />
<PackageReference Include="Moq" Version="4.9.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 0 additions & 4 deletions src/Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,4 @@
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
</ItemGroup>
</Project>
11 changes: 5 additions & 6 deletions src/Core/DataLoaderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,12 @@ public Task<TValue> LoadAsync(TKey key)

if (_options.Batching)
{
if (!_buffer.TryAdd(resolvedKey, promise))
{
if (_buffer.TryGetValue(resolvedKey,
if (!_buffer.TryAdd(resolvedKey, promise) &&
_buffer.TryGetValue(resolvedKey,
out TaskCompletionSource<TValue> value))
{
promise = value;
}
{
promise.TrySetCanceled();
promise = value;
}
}
else
Expand Down

0 comments on commit 171f686

Please sign in to comment.