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

Use static lambdas to better express intent concisely #47468

Merged
2 commits merged into from
Sep 5, 2020

Conversation

CyrusNajmabadi
Copy link
Member

These are a couple of areas where we switched, in the past, from a normal lambda to a static delegate to ensure we didn't accidentally capture something. The original changes were done because the captures ended up causing perf issues, and we wanted to make sure we didn't accidentally regress this.

We can now state this simply in the source by explicitly using a static-lambda. These lambdas now convey explicitly that they shoudl not capture, and it's no longer possible to accidentally cause them to do so (without a very obvious textual change on the declaration).

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner September 4, 2020 21:35
@@ -64,10 +64,9 @@ public Accessor(SQLitePersistentStorage storage)

[PerformanceSensitive("https://github.com/dotnet/roslyn/issues/36114", AllowCaptures = false)]
Copy link
Member Author

Choose a reason for hiding this comment

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

would be nifty if something validated this automatically. for now though, we have the attribute declaring intent, and we can ensure it is followed by use of static lambdas.

Copy link
Member

Choose a reason for hiding this comment

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

That's the plan for PerfSensitiveAnalyzer, we just never get time to work on that

@ghost
Copy link

ghost commented Sep 4, 2020

Hello @CyrusNajmabadi!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Auto-approval

@ghost ghost merged commit 4556e57 into dotnet:master Sep 5, 2020
@ghost ghost added this to the Next milestone Sep 5, 2020
@dibarbet dibarbet modified the milestones: Next, 16.8.P4 Sep 22, 2020
@CyrusNajmabadi CyrusNajmabadi deleted the staticLambdas branch April 11, 2021 18:23
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants