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

Support WeakReferences in NodeConnectingVisitor #1057

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Jan 1, 2025

closes #1055

we observed perf improvements on a similar visitor in staabm/phpstan-dba#667 (comment)

@staabm
Copy link
Contributor Author

staabm commented Jan 1, 2025

I think in CloningVisitor we don't need a weak-ref because we clone the elements, right?

if ($this->weakReferences) {
$parent = \WeakReference::create($parent);
}
$node->setAttribute('parent', $parent);
Copy link
Owner

Choose a reason for hiding this comment

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

One thing I'm wondering about here is whether we should reuse the same attribute names, or use a different one like 'weak_parent', to avoid having two possible types for these attributes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could use separate attribute names, but then I would go with a separate WeakNodeConnectingVisitor class and leave NodeConnectingVisitor untouched ..?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

adjusted

Copy link
Owner

Choose a reason for hiding this comment

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

Given that the implementation themselves are pretty trivial, I'd be fine with adding separate classes as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am fine with the PR as is, in case you are also ok with it

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.

Inefficient NodeConnectingVisitor
2 participants