Skip to content

Commit 819071f

Browse files
authored
Release a SeparatedSyntaxListBuilder back to the SyntaxListPool (#76635)
I noticed this when looking at the SyntaxListPool and that it's allocated debug info was not reducing back to zero. The early return codepaths earlier in the method are commonly hit avoiding the current code from releasing "variables" back into the pool. Changed to account for the early returns by utilizing the existing finally block similar to what is done for the "mods" pooled item.
1 parent 3e85c6a commit 819071f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Compilers/CSharp/Portable/Parser/LanguageParser.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10123,11 +10123,12 @@ private StatementSyntax ParseLocalDeclarationStatement(SyntaxList<AttributeListS
1012310123
awaitKeyword,
1012410124
usingKeyword,
1012510125
mods.ToList(),
10126-
_syntaxFactory.VariableDeclaration(type, _pool.ToListAndFree(variables)),
10126+
_syntaxFactory.VariableDeclaration(type, variables.ToList()),
1012710127
this.EatToken(SyntaxKind.SemicolonToken));
1012810128
}
1012910129
finally
1013010130
{
10131+
_pool.Free(variables);
1013110132
_pool.Free(mods);
1013210133
}
1013310134
}

0 commit comments

Comments
 (0)