Skip to content

Commit

Permalink
refactor: use HashSet instead of Dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
aneojgurhem committed Sep 25, 2023
1 parent 5abcce1 commit 0b9e044
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/csharp/ArmoniK.Api.Client/EventsClientExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ public static async Task WaitForResultsAsync(this Events.EventsClient client,
ICollection<string> resultIds,
CancellationToken cancellationToken)
{
var resultsNotFound = resultIds.ToDictionary(id => id,
_ => true);
var resultsNotFound = new HashSet<string>(resultIds);

using var streamingCall = client.GetEvents(new EventSubscriptionRequest
{
Expand All @@ -99,12 +98,11 @@ public static async Task WaitForResultsAsync(this Events.EventsClient client,
},
});


while (await streamingCall.ResponseStream.MoveNext(cancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
var resp = streamingCall.ResponseStream.Current;
if (resp.UpdateCase == EventSubscriptionResponse.UpdateOneofCase.ResultStatusUpdate && resultsNotFound.ContainsKey(resp.ResultStatusUpdate.ResultId))
if (resp.UpdateCase == EventSubscriptionResponse.UpdateOneofCase.ResultStatusUpdate && resultsNotFound.Contains(resp.ResultStatusUpdate.ResultId))
{
if (resp.ResultStatusUpdate.Status == ResultStatus.Completed)
{
Expand All @@ -121,7 +119,7 @@ public static async Task WaitForResultsAsync(this Events.EventsClient client,
}
}

if (resp.UpdateCase == EventSubscriptionResponse.UpdateOneofCase.NewResult && resultsNotFound.ContainsKey(resp.NewResult.ResultId))
if (resp.UpdateCase == EventSubscriptionResponse.UpdateOneofCase.NewResult && resultsNotFound.Contains(resp.NewResult.ResultId))
{
if (resp.NewResult.Status == ResultStatus.Completed)
{
Expand Down

0 comments on commit 0b9e044

Please sign in to comment.