Skip to content

Conversation

@samsonasik
Copy link
Contributor

@samsonasik samsonasik commented Oct 20, 2025

@samsonasik
Copy link
Contributor Author

Ready for review 👍

@carlos-granados
Copy link

In the case of Rector, this was used to optimise the running time by 20-30%. Probably other tools could benefit from similar optimisations

@TomasVotruba
Copy link
Contributor

The 20-30 % speedup was really noticable across many mid-large size projects 👍
It would also open-up even more advanced speed improvements based on full node class -> visitor tree.

/**
* @return NodeVisitor[]
*/
public function getVisitorsForNode(Node $node) {
Copy link
Owner

@nikic nikic Oct 20, 2025

Choose a reason for hiding this comment

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

Should probably be protected and have array return type?

Would also be good to add a doc comment to explain that this is an extension point, as the method doesn't make a lot of sense in itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, updated to protected, add array return type, and add doc comment why it is needed.

@nikic
Copy link
Owner

nikic commented Oct 20, 2025

It looks like adding this method makes NodeTraverser itself about 10% slower.

@samsonasik
Copy link
Contributor Author

@nikic could you share script to verify the benchmark? Thank you.

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