Skip to content

Commit

Permalink
100880 set 4 changes (#4604)
Browse files Browse the repository at this point in the history
Updates for IEnnumerable to avoid multiple enumerations

Refs AB#100880
  • Loading branch information
v-ajajvanu authored Sep 16, 2024
1 parent 873d1d4 commit 94bc85e
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace Microsoft.Health.Fhir.Api.Features.Formatters
public sealed class FormatParametersValidator : IFormatParametersValidator
{
private readonly IConformanceProvider _conformanceProvider;
private readonly ICollection<TextOutputFormatter> _outputFormatters;
private readonly IEnumerable<TextOutputFormatter> _outputFormatters;
private readonly ConcurrentDictionary<ResourceFormat, bool> _supportedFormats = new ConcurrentDictionary<ResourceFormat, bool>();
private readonly ConcurrentDictionary<string, bool> _supportedPatchFormats = new ConcurrentDictionary<string, bool>();

Expand Down Expand Up @@ -62,7 +62,7 @@ public async Task CheckRequestedContentTypeAsync(HttpContext httpContext)
throw new NotAcceptableException(Api.Resources.UnsupportedFormatParameter);
}

string closestClientMediaType = _outputFormatters.GetClosestClientMediaType(resourceFormat.ToContentType(), acceptHeaders?.Select(x => x.MediaType.Value));
string closestClientMediaType = _outputFormatters.GetClosestClientMediaType(resourceFormat.ToContentType(), acceptHeaders?.Select(x => x.MediaType.Value)?.ToList());

// Overrides output format type
httpContext.Response.ContentType = closestClientMediaType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ private static void SetupContexts(
}
}

private void PopulateReferenceIdDictionary(IEnumerable<EntryComponent> bundleEntries, IDictionary<string, (string resourceId, string resourceType)> idDictionary)
private void PopulateReferenceIdDictionary(IReadOnlyCollection<EntryComponent> bundleEntries, IDictionary<string, (string resourceId, string resourceType)> idDictionary)
{
foreach (EntryComponent entry in bundleEntries)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public IEnumerable<string> GetSupportedProfiles(string resourceType, bool disabl
.Select(x => x.ResourceUri).ToList();
}

private static string GetHashForSupportedProfiles(IEnumerable<ArtifactSummary> summaries)
private static string GetHashForSupportedProfiles(IReadOnlyCollection<ArtifactSummary> summaries)
{
if (summaries == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ internal static IEnumerable<long> GetOffsets(long blobLength, int bytesToRead)
}
}

private async Task<IList<long>> EnqueueProcessingJobsAsync(IEnumerable<InputResource> inputs, long groupId, ImportOrchestratorJobDefinition coordDefinition, CancellationToken cancellationToken)
private async Task<IList<long>> EnqueueProcessingJobsAsync(IReadOnlyCollection<InputResource> inputs, long groupId, ImportOrchestratorJobDefinition coordDefinition, CancellationToken cancellationToken)
{
var definitions = new List<ImportProcessingJobDefinition>();
foreach (var input in inputs.OrderBy(_ => RandomNumberGenerator.GetInt32((int)1e9)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,11 @@ internal async Task<IReadOnlyList<string>> ImportResourcesAsync(IReadOnlyList<Im
}
}

var dups = resources.Except(results.Loaded).Except(results.Conflicts);
var dups = resources.Except(results.Loaded).Except(results.Conflicts)?.ToList();

return GetErrors(dups, results.Conflicts);

List<string> GetErrors(IEnumerable<ImportResource> dups, IEnumerable<ImportResource> conflicts)
List<string> GetErrors(IReadOnlyCollection<ImportResource> dups, IReadOnlyCollection<ImportResource> conflicts)
{
var errors = new List<string>();
foreach (var resource in dups)
Expand Down
2 changes: 1 addition & 1 deletion tools/Exporter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private static int Export(short resourceTypeId, BlobContainerClient container, l
return strings.Count;
}

private static void WriteBatchOfLines(BlobContainerClient container, IEnumerable<string> batch, string blobName)
private static void WriteBatchOfLines(BlobContainerClient container, IReadOnlyCollection<string> batch, string blobName)
{
retry:
try
Expand Down
4 changes: 2 additions & 2 deletions tools/PerfTester/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ private static void ExecuteParallelCalls(ReadOnlyList<(short ResourceTypeId, str
}
else if (_callType.StartsWith("SearchByIds"))
{
var status = GetResources(_nameFilter, resourceIds.Item2.Select(_ => _.ResourceId));
var status = GetResources(_nameFilter, resourceIds.Item2.Select(_ => _.ResourceId)?.ToList());
if (status != "OK")
{
Interlocked.Increment(ref errors);
Expand Down Expand Up @@ -793,7 +793,7 @@ private static string PostBundle(string jsonString, string resourceType, string
return status;
}

private static string GetResources(string resourceType, IEnumerable<string> resourceIds)
private static string GetResources(string resourceType, System.Collections.Generic.IReadOnlyCollection<string> resourceIds)
{
var maxRetries = 3;
var retries = 0;
Expand Down

0 comments on commit 94bc85e

Please sign in to comment.