这是indexloc提供的服务,不要输入任何密码
Skip to content

ServiceExtensionManager: return early... earlier #9287

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

Merged
merged 2 commits into from
Jul 2, 2025

Conversation

srawlins
Copy link
Contributor

@srawlins srawlins commented Jul 2, 2025

I found two little opportunities to be null safe and theoretically avoid creating a local closure.

In the first, we create a local variable, final mainIsolate, and then create a large local closure, callExtension. Then we check if that local variable is null, in order to return early. Moving that check, and one more, above the closure declaration adds three benefits: (1) the variable is promoted to be non-null, (2) the code reads a little easier, grouping these return early checks, and (3) we avoid creating the local closure when we don't need it, potentially saving memory.

The second is very similar to the first.

@srawlins srawlins merged commit 4bebd62 into flutter:master Jul 2, 2025
41 of 42 checks passed
@srawlins srawlins deleted the nits-2 branch July 2, 2025 21:33
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.

2 participants