-
Notifications
You must be signed in to change notification settings - Fork 466
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
base: main
Are you sure you want to change the base?
Dispose some pooled object instances #7330
Conversation
We Dispose()/Free() other instances of these classes, but not these specific ones. Fix that.
@@ -68,7 +68,7 @@ public override void Initialize(AnalysisContext context) | |||
|
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
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 |
There was a problem hiding this 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(); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ImmutableHashSet<object?> mergedLiteralValues = builder.ToImmutable(); | |
ImmutableHashSet<object?> mergedLiteralValues = builder.ToImmutableAndClear(); |
We Dispose()/Free() other instances of these classes, but not these specific ones. Fix that.