csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

perf: add `Doc.Null` check to `Argument` avoids `Concat` creation

Open TimothyMakkison opened this issue 2 months ago • 0 comments

Add check for if modifiers are Doc.Null to avoid allocating a Concat and Doc[]

Benchmarks (timing is inaccurate)

Before

Method Mean Error StdDev Median Gen0 Gen1 Allocated
Default_CodeFormatter_Tests 131.9 ms 3.30 ms 8.86 ms 128.0 ms 3000.0000 1000.0000 34.57 MB
Default_CodeFormatter_Complex 261.3 ms 5.16 ms 4.03 ms 261.3 ms 5000.0000 2000.0000 53.03 MB

After

Method Mean Error StdDev Median Gen0 Gen1 Allocated
Default_CodeFormatter_Tests 189.5 ms 10.25 ms 28.05 ms 195.6 ms 3000.0000 1000.0000 34.31 MB
Default_CodeFormatter_Complex 264.2 ms 5.27 ms 13.97 ms 260.0 ms 5000.0000 2000.0000 52.31 MB

TimothyMakkison avatar Oct 14 '25 10:10 TimothyMakkison