Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispose some pooled object instances #7330

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

omajid
Copy link
Member

@omajid omajid commented Jun 14, 2024

We Dispose()/Free() other instances of these classes, but not these specific ones. Fix that.

We Dispose()/Free() other instances of these classes, but not these
specific ones. Fix that.
@omajid omajid requested a review from a team as a code owner June 14, 2024 17:00
@@ -68,7 +68,7 @@ public override void Initialize(AnalysisContext context)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does interfaceToGenericInterfaceMapBuilder need to be Dispose()d too?

@@ -261,7 +261,7 @@ internal ValueContentAbstractValue IntersectLiteralValues(ValueContentAbstractVa
}

// Merge Literals
var builder = PooledHashSet<object?>.GetInstance();
using var builder = PooledHashSet<object?>.GetInstance();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will Dispose() on the error path (return MaybeContainsNonLiteralState) too.

Copy link

codecov bot commented Jun 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.49%. Comparing base (52913b2) to head (b054267).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7330   +/-   ##
=======================================
  Coverage   96.49%   96.49%           
=======================================
  Files        1443     1443           
  Lines      345670   345670           
  Branches    11370    11370           
=======================================
+ Hits       333543   333559   +16     
+ Misses       9248     9233   -15     
+ Partials     2879     2878    -1     

Copy link
Member

@sharwell sharwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see this PR make use of ToImmutableAndClear() to avoid unnecessary array copies when data is extracted from the builder.

@@ -68,7 +68,7 @@ public override void Initialize(AnalysisContext context)

if (wellKnownTypeProvider.TryGetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemCollectionsIList, out var iListType))
{
var builder = ArrayBuilder<INamedTypeSymbol>.GetInstance();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 The ToImmutable() line should also change to ToImmutableAndClear()

@@ -79,7 +79,7 @@ public override void Initialize(AnalysisContext context)

if (wellKnownTypeProvider.TryGetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemCollectionsICollection, out var iCollectionType))
{
var builder = ArrayBuilder<INamedTypeSymbol>.GetInstance();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 The ToImmutable() line should also change to ToImmutableAndClear()

@@ -275,7 +275,7 @@ internal ValueContentAbstractValue IntersectLiteralValues(ValueContentAbstractVa
}
}

ImmutableHashSet<object?> mergedLiteralValues = builder.ToImmutableAndFree();
ImmutableHashSet<object?> mergedLiteralValues = builder.ToImmutable();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ImmutableHashSet<object?> mergedLiteralValues = builder.ToImmutable();
ImmutableHashSet<object?> mergedLiteralValues = builder.ToImmutableAndClear();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants