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

UseImportsTraverser optimization opportunity #8194

Closed
staabm opened this issue Sep 11, 2023 · 0 comments · Fixed by rectorphp/rector-src#4994
Closed

UseImportsTraverser optimization opportunity #8194

staabm opened this issue Sep 11, 2023 · 0 comments · Fixed by rectorphp/rector-src#4994
Labels

Comments

@staabm
Copy link
Contributor

staabm commented Sep 11, 2023

looking at a codeigniter profile, I can see UseImportsTraverser to use a considerable amount of time

grafik

In the UseImportsTraverser I can see it is using SimpleCallableNodeTraverser to deep travers statements.

looking at the php-src docs I noted..

The use keyword must be declared in the outermost scope of a file (the global scope) or inside namespace declarations. This is because the importing is done at compile time and not runtime, so it cannot be block scoped. The following example will show an illegal use of the use keyword

doesn't this mean, that we can stop traversing the statements in UseImportsTraverser as soon as we hit a function or class?
(or maybe at leaset it means we need only a linear scan of the top level and no deep traversal).

leaving it here for discussion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant