-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
Cleaning up the doc tree #445
Conversation
3e6a10c
to
483d684
Compare
Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseMethodDeclaration.cs
Outdated
Show resolved
Hide resolved
|
||
if (arguments.Any()) | ||
{ | ||
docs.Add( |
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.
Why is this change needed?
I'm not saying I prefer the old code over this, but I would like to understand why you're doing this.
Is there some penalty for having Doc.Null
? If yes, wouldn't it be easier to filter them out in Doc.Concat()
, causing them to be removed everywhere?
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.
There is probably some minor overhead to having Doc.Null
in a Doc.Concat
. The main goal of this was to clean some of them out of the displayed doc tree so it was easier to see what was going in with methods.
I always assumed stripping them out of the List<Doc>
inside of Concat
wouldn't be worth it and finally decided to benchmark it. Stripping them out does cause formatting to be ~2.4% slower and take ~2.9% more ram, at least on this very large file I use for benchmarking.
Maybe I should just modify the playground site to not show Doc.Null
, or have an option to not show it.... that seems way easier. It does have some slight risk that the Doc.Null
is affecting the formatting, but doesn't show in the doc tree.
cefa7c4
to
c9db724
Compare
This PR cleans up the doc that we generate, which helps when trying to understand how code is being formatted. It probably also has some minor performance gains.