Use HashSet constructor (#2742)

This commit is contained in:
Michael Maxwell 2021-12-13 06:48:42 -08:00 committed by GitHub
parent 5d9083b973
commit f3eaf4a6f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 18 deletions

View File

@ -79,12 +79,7 @@ namespace OpenTelemetry.Metrics
{
this.updateLongCallback = this.UpdateLongCustomTags;
this.updateDoubleCallback = this.UpdateDoubleCustomTags;
var hs = new HashSet<string>(StringComparer.Ordinal);
foreach (var key in tagKeysInteresting)
{
hs.Add(key);
}
var hs = new HashSet<string>(tagKeysInteresting, StringComparer.Ordinal);
this.tagKeysInteresting = hs;
this.tagsKeysInterestingCount = hs.Count;
}

View File

@ -89,12 +89,7 @@ namespace OpenTelemetry.Metrics
}
else if (meterSources.Any())
{
var meterSourcesToSubscribe = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (var meterSource in meterSources)
{
meterSourcesToSubscribe.Add(meterSource);
}
var meterSourcesToSubscribe = new HashSet<string>(meterSources, StringComparer.OrdinalIgnoreCase);
shouldListenTo = instrument => meterSourcesToSubscribe.Contains(instrument.Meter.Name);
}

View File

@ -242,12 +242,7 @@ namespace OpenTelemetry.Trace
}
else
{
var activitySources = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (var name in sources)
{
activitySources.Add(name);
}
var activitySources = new HashSet<string>(sources, StringComparer.OrdinalIgnoreCase);
if (this.supportLegacyActivity)
{