-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DomCrawler] minor performance improvement #26423
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
Conversation
dunglas
commented
Mar 6, 2018
•
edited by nicolas-grekas
Loading
edited by nicolas-grekas
Q | A |
---|---|
Branch? | master |
Bug fix? | no |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | n/a |
License | MIT |
Doc PR | n/a |
Changing weak to strict comparison in public method is potentially breaking change and should not be done in patch release |
@ostrolucky not here, because the test is in a |
I know Also, it seems this provides no performance boost if data types compared are same https://stackoverflow.com/a/14520998/524965 |
I agree with @ostrolucky about the strict comparison: this kind of changes is too risky in a patch version. Better do that in master. Thanks! |
How big is the performance gain? |
@jakzal I've not benchmarked it, but on large documents it should be important (calling a method in a loop for nothing always come with a big cost). |
Looks like there are some unrelated commits here. |
8d80108
to
d615fc9
Compare
@fabpot Fixed. @ostrolucky @javiereguiluz the comparison has already been removed in master, problem fixed! |
do { | ||
if ($node !== $this->getNode(0) && 1 === $node->nodeType) { | ||
if ($node !== $currentNode && 1 === $node->nodeType) { |
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.
Minor thing: why not use XML_ELEMENT_NODE === $node->nodeType
instead of 1 === $node->nodeType
? It's more readable to use http://php.net/manual/en/dom.constants.php and we already do that in other parts of this same class.
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.
I agree, can I do it in the same PR?
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.
done
Thank you @dunglas. |
This PR was squashed before being merged into the 4.1-dev branch (closes #26423). Discussion ---------- [DomCrawler] minor performance improvement | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? |no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | n/a <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | n/a Commits ------- eead301 [DomCrawler] minor performance improvement