Skip to content
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

Merged
merged 4 commits into from
Oct 15, 2021
Merged

Cleaning up the doc tree #445

merged 4 commits into from
Oct 15, 2021

Conversation

belav
Copy link
Owner

@belav belav commented Sep 27, 2021

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.

@belav belav force-pushed the clean-up-doc-tree branch 3 times, most recently from 3e6a10c to 483d684 Compare September 27, 2021 21:33
shocklateboy92
shocklateboy92 previously approved these changes Oct 1, 2021
Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Argument.cs Outdated Show resolved Hide resolved

if (arguments.Any())
{
docs.Add(
Copy link
Collaborator

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?

Copy link
Owner Author

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.

@belav belav force-pushed the clean-up-doc-tree branch from cefa7c4 to c9db724 Compare October 10, 2021 23:19
@belav belav merged commit f41eca7 into master Oct 15, 2021
@belav belav deleted the clean-up-doc-tree branch October 15, 2021 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants