C++: Fix join order in getAnOverload#4891
Merged
Merged
Conversation
7655799 to
454605b
Compare
jbj
reviewed
Jan 4, 2021
Contributor
jbj
left a comment
There was a problem hiding this comment.
Otherwise LGTM. Function.getAnOverload is inherently quadratic, so it's probably best to avoid it in production queries even with this improvement.
Comment on lines
+397
to
+401
| // If this function is declared in a class, only consider other | ||
| // functions from the same class. | ||
| exists(string name, Namespace namespace, Class declaringType | | ||
| candGetAnOverloadMember(name, namespace, declaringType, this) and | ||
| candGetAnOverloadMember(name, namespace, declaringType, result) |
Contributor
There was a problem hiding this comment.
I believe there's no need for a namespace parameter on candGetAnOverloadMember. If two functions are in the same class, they must also be in the same namespace.
Comment on lines
394
to
395
| /** Gets a function that overloads this one. */ | ||
| Function getAnOverload() { |
Contributor
There was a problem hiding this comment.
Given #4889 (comment), I suggest you add a remark to this QLDoc to say that if overrides are wanted rather than overloads then MemberFunction::getAnOverridingFunction should be used instead.
Contributor
Author
There was a problem hiding this comment.
That's a good idea! I've added such a remark in 134982c.
e4726db to
134982c
Compare
jbj
approved these changes
Jan 4, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Fixes #4889.
There was a bad join-order that caused a blowup in
getAnOverload. I don't know if this is the smallest possible diff, but I think it'll reduce the likelihood of a bad join-order in the future.Here are the tuple counts before and after this PR on the query:
Notice that the final
#sharedpredicate has the same number of tuples (and similarly for#select).Before:
After:
CPP-difference: https://jenkins.internal.semmle.com/job/Changes/job/CPP-Differences/1646/