Skip to content

Commit

Permalink
Dispose some pooled object instances
Browse files Browse the repository at this point in the history
We Dispose()/Free() other instances of these classes, but not these
specific ones. Fix that.
  • Loading branch information
omajid committed Jun 14, 2024
1 parent 52913b2 commit b054267
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public override void Initialize(AnalysisContext context)
if (wellKnownTypeProvider.TryGetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemCollectionsIList, out var iListType))
{
var builder = ArrayBuilder<INamedTypeSymbol>.GetInstance();
using var builder = ArrayBuilder<INamedTypeSymbol>.GetInstance();
builder.AddIfNotNull(wellKnownTypeProvider.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemCollectionsGenericIList1));
builder.AddIfNotNull(wellKnownTypeProvider.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemCollectionsGenericIReadOnlyList1));
if (builder.Count > 0)
Expand All @@ -79,7 +79,7 @@ public override void Initialize(AnalysisContext context)
if (wellKnownTypeProvider.TryGetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemCollectionsICollection, out var iCollectionType))
{
var builder = ArrayBuilder<INamedTypeSymbol>.GetInstance();
using var builder = ArrayBuilder<INamedTypeSymbol>.GetInstance();
builder.AddIfNotNull(wellKnownTypeProvider.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemCollectionsGenericICollection1));
builder.AddIfNotNull(wellKnownTypeProvider.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemCollectionsGenericIReadOnlyCollection1));
if (builder.Count > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,7 @@ static void MergePlatformAttributes(ImmutableArray<AttributeData> immediateAttri
var pAttributes = parentAttributes.Platforms;
if (pAttributes != null && !pAttributes.IsEmpty)
{
var notFoundPlatforms = PooledHashSet<string>.GetInstance();
using var notFoundPlatforms = PooledHashSet<string>.GetInstance();
bool supportFound = false;
foreach (var (platform, attributes) in pAttributes)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ internal ValueContentAbstractValue MergeBinaryOperation(
}

// Merge Literals
var builder = PooledHashSet<object?>.GetInstance();
using var builder = PooledHashSet<object?>.GetInstance();
foreach (var leftLiteral in LiteralValues)
{
foreach (var rightLiteral in otherState.LiteralValues)
Expand All @@ -275,7 +275,7 @@ internal ValueContentAbstractValue MergeBinaryOperation(
}
}

ImmutableHashSet<object?> mergedLiteralValues = builder.ToImmutableAndFree();
ImmutableHashSet<object?> mergedLiteralValues = builder.ToImmutable();
ValueContainsNonLiteralState mergedNonLiteralState = Merge(NonLiteralState, otherState.NonLiteralState);

return Create(mergedLiteralValues, mergedNonLiteralState);
Expand Down

0 comments on commit b054267

Please sign in to comment.