-
-
Notifications
You must be signed in to change notification settings - Fork 918
Refactor cycle breaking (visited tracking) in SubresourceOperationFactory #1279
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
Refactor cycle breaking (visited tracking) in SubresourceOperationFactory #1279
Conversation
PHPStan failure should be addressed in a separate PR. |
|
||
$this->computeSubresourceOperations($subresourceClass, $tree, $rootResourceClass, $operation, $visiting); | ||
$this->computeSubresourceOperations($subresourceClass, $tree, $rootResourceClass, $operation, array_merge($visited, [$visiting])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$visited[] = $visiting;
$this->computeSubresourceOperations(..., $visited);
Is it not better for performance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that would give the wrong result. We could of course use another variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum, I think I missed something here... Why is the result wrong? It's not an associative array here, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result would be wrong because we have a loop, if we modify the $visited
array in place it'd affect the other properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, I missed the loop! BTW it's better like this with an associative array! 👍
9a8de56
to
f6fc45d
Compare
Merged in #1283 Thanks @teohhanhui |
…tory
Refactor with visited tracking logic which is much easier to follow.