Minor improvement for the case that hashset is sufficient. (#2467)

This commit is contained in:
yunl 2021-10-14 13:41:53 -07:00 committed by GitHub
parent 32760fd47d
commit c7a27dca06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -241,21 +241,21 @@ namespace OpenTelemetry.Trace
}
else
{
var activitySources = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
var activitySources = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (var name in sources)
{
activitySources[name] = true;
activitySources.Add(name);
}
if (this.supportLegacyActivity)
{
activitySources[string.Empty] = true;
activitySources.Add(string.Empty);
}
// Function which takes ActivitySource and returns true/false to indicate if it should be subscribed to
// or not.
listener.ShouldListenTo = (activitySource) => activitySources.ContainsKey(activitySource.Name);
listener.ShouldListenTo = (activitySource) => activitySources.Contains(activitySource.Name);
}
}
else