-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Optimize suppress operations during formatting. #73456
Optimize suppress operations during formatting. #73456
Conversation
@@ -58,6 +59,25 @@ internal static class ListExtensions | |||
list.RemoveRange(targetIndex, list.Count - targetIndex); | |||
} | |||
|
|||
public static void RemoveOrTransformAll<T, TArg>(this ArrayBuilder<T> list, Func<T, TArg, T?> transform, TArg arg) |
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.
copy of the method above. just for ArrayBuilders.
@@ -53,7 +55,6 @@ private class InitialContextFinder | |||
if (initialSuppressOperations != null) | |||
{ | |||
Debug.Assert( | |||
initialSuppressOperations.IsEmpty() || |
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.
redundant with line below.
@@ -176,6 +176,20 @@ private static void AddOperations<T>(SegmentedList<T> operations, List<T> scratc | |||
scratch.Clear(); | |||
} | |||
|
|||
private static void AddOperations<T>(SegmentedList<T> operations, ArrayBuilder<T> scratch, SyntaxNode node, Action<ArrayBuilder<T>, SyntaxNode> addOperations) |
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.
copy of method above, just for array builders.
var list = new List<SuppressOperation>(); | ||
chainedFormattingRules.AddSuppressOperations(list, node); | ||
return list; | ||
} |
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.
not called at all.
@@ -18,7 +19,7 @@ protected abstract class CompatAbstractMetadataFormattingRule : AbstractMetadata | |||
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member | |||
[Obsolete("Do not call this method directly (it will Stack Overflow).", error: true)] | |||
[EditorBrowsable(EditorBrowsableState.Never)] | |||
public sealed override void AddSuppressOperations(List<SuppressOperation> list, SyntaxNode node, in NextSuppressOperationAction nextOperation) | |||
public sealed override void AddSuppressOperations(ArrayBuilder<SuppressOperation> list, SyntaxNode node, in NextSuppressOperationAction nextOperation) |
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 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.
maybe one more based on traces. but i'd like to do it one at a time, and based on need.
} | ||
|
||
// make sure we order align operation from left to right | ||
alignmentOperation.Sort(static (o1, o2) => o1.BaseToken.Span.CompareTo(o2.BaseToken.Span)); |
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 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.
Drops us from:
To: