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

Optimize suppress operations during formatting. #73456

Merged
merged 3 commits into from
May 13, 2024

Conversation

CyrusNajmabadi
Copy link
Member

Drops us from:

image

To:

image

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 13, 2024 21:33
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels May 13, 2024
@CyrusNajmabadi CyrusNajmabadi requested a review from ToddGrun May 13, 2024 21:33
@@ -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)
Copy link
Member Author

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() ||
Copy link
Member Author

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)
Copy link
Member Author

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;
}
Copy link
Member Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ArrayBuilder

Not worth doing for the other Add* methods in this file?

Copy link
Member Author

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.

@CyrusNajmabadi CyrusNajmabadi requested a review from ToddGrun May 13, 2024 22:03
}

// make sure we order align operation from left to right
alignmentOperation.Sort(static (o1, o2) => o1.BaseToken.Span.CompareTo(o2.BaseToken.Span));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alignmentOperation

was this a bug before?

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@CyrusNajmabadi CyrusNajmabadi enabled auto-merge May 13, 2024 22:12
@CyrusNajmabadi CyrusNajmabadi merged commit 74093fd into dotnet:main May 13, 2024
28 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone May 13, 2024
@CyrusNajmabadi CyrusNajmabadi deleted the suppressionOperations branch May 14, 2024 01:58
@Cosifne Cosifne modified the milestones: Next, 17.11 P2 May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants