Skip to content

AST: Request-ify ValueDecl::findImport() #72758

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 1 commit into from
Apr 2, 2024

Conversation

tshortli
Copy link
Contributor

@tshortli tshortli commented Apr 2, 2024

To prevent performance regressions from calling findImport() more frequently, request-ify the computation.

NFC.

Prerequisite of rdar://16154294

To prevent performance regressions from calling `findImport()` more frequently,
request-ify the computation.

NFC.

Prerequisite of rdar://16154294
@tshortli
Copy link
Contributor Author

tshortli commented Apr 2, 2024

@swift-ci please smoke test

auto &ctx = sf->getASTContext();
auto imports = sf->getImports();

// Look to see if the owning module was directly imported.
Copy link
Contributor

Choose a reason for hiding this comment

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

There's an overload of ImportCache::getImportSet() that takes an ArrayRef. Maybe it can replace this whole thing?

Copy link
Contributor

Choose a reason for hiding this comment

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

This was originally located in TypeCheckConcurrency, so there is a high chance that it’s possible to dedupe…

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like ImportSet is a flat set of imports, so the context of which top level import each transitive import comes from is lost. Correct me if I'm missing something but I don't see how that can be used to implement this request that needs to return the specific import from which a module is reachable.

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me!

@tshortli tshortli merged commit c3b6a1a into swiftlang:main Apr 2, 2024
@tshortli tshortli deleted the requestify-find-import branch April 2, 2024 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants