-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Remove array allocations for formatting rules. #73458
Conversation
@@ -30,10 +31,10 @@ internal static IEnumerable<AbstractFormattingRule> GetDefaultFormattingRules(IS | |||
/// <param name="cancellationToken">An optional cancellation token.</param> | |||
/// <returns>The formatted tree's root node.</returns> | |||
public static SyntaxNode Format(SyntaxNode node, ISyntaxFormatting syntaxFormattingService, SyntaxFormattingOptions options, CancellationToken cancellationToken) | |||
=> Format(node, [node.FullSpan], syntaxFormattingService, options, rules: null, cancellationToken: cancellationToken); | |||
=> Format(node, [node.FullSpan], syntaxFormattingService, options, rules: default, cancellationToken: cancellationToken); |
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.
changed things to be explicitly ImmutableArrays, not IEnumerables. So lots of fallout of that.
@@ -45,21 +46,35 @@ internal abstract partial class AbstractFormatEngine | |||
internal readonly SyntaxFormattingOptions Options; | |||
internal readonly TreeData TreeData; | |||
|
|||
private static readonly object s_gate = new(); | |||
private static (ImmutableArray<AbstractFormattingRule> formattingRules, SyntaxFormattingOptions options, ChainedFormattingRules chainedRules) s_lastRulesAndOptions; |
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.
this is the crux of hte change.
} | ||
|
||
return true; | ||
}).ToImmutableArray(); | ||
}); |
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.
i want an analyzer for this.
...table/GenerateEqualsAndGetHashCodeFromMembers/AbstractGenerateEqualsAndGetHashCodeService.cs
Outdated
Show resolved
Hide resolved
...kspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/Engine/AbstractFormatEngine.cs
Outdated
Show resolved
Hide resolved
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.
Removes effectively all of these allocatinos: