Skip to content

Commit 0349524

Browse files
perf: set capacity of List in MembersForcedLine (#1709)
Most `result` Lists are always just under `3 * members.Count`, small change but simple 🤷 ### Benchmarks (timing is inaccurate should be the same) #### Before | Method | Mean | Error | StdDev | Gen0 | Gen1 | Allocated | |------------------------------ |---------:|--------:|--------:|----------:|----------:|----------:| | Default_CodeFormatter_Tests | 133.0 ms | 2.56 ms | 2.84 ms | 3000.0000 | 1000.0000 | 34.58 MB | | Default_CodeFormatter_Complex | 271.5 ms | 5.40 ms | 7.92 ms | 5000.0000 | 2000.0000 | 52.95 MB | #### After | Method | Mean | Error | StdDev | Gen0 | Gen1 | Allocated | |------------------------------ |---------:|--------:|--------:|----------:|----------:|----------:| | Default_CodeFormatter_Tests | 132.4 ms | 2.64 ms | 3.87 ms | 3000.0000 | 1000.0000 | 34.56 MB | | Default_CodeFormatter_Complex | 268.2 ms | 4.92 ms | 4.60 ms | 5000.0000 | 2000.0000 | 52.78 MB | Co-authored-by: Bela VanderVoort <[email protected]>
1 parent a8ddbc3 commit 0349524

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Src/CSharpier.Core/CSharp/SyntaxPrinter/MembersWithForcedLines.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static List<Doc> Print<T>(
2020
)
2121
where T : MemberDeclarationSyntax
2222
{
23-
var result = new List<Doc>();
23+
var result = new List<Doc>(members.Count * 3);
2424
if (!skipFirstHardLine)
2525
{
2626
result.Add(Doc.HardLine);

0 commit comments

Comments
 (0)