-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Rust: Speedup inferMethodCallTypeSelf
#21305
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,9 @@ module Make<LocationSig Location, InputSig<Location> Input> { | |
| /** Holds if this list is empty. */ | ||
| predicate isEmpty() { this = "" } | ||
|
|
||
| bindingset[this] | ||
| private int stringLength() { result = super.length() } | ||
|
|
||
| /** Gets the length of this list. */ | ||
| bindingset[this] | ||
| pragma[inline_late] | ||
|
|
@@ -115,19 +118,23 @@ module Make<LocationSig Location, InputSig<Location> Input> { | |
| /** Holds if this list starts with `e`, followed by `suffix`. */ | ||
| bindingset[this] | ||
| predicate isCons(Element e, UnboundList suffix) { | ||
| exists(string regexp | regexp = "^([0-9]+)\\.(.*)$" | | ||
| e = decode(this.regexpCapture(regexp, 1)) and | ||
| suffix = this.regexpCapture(regexp, 2) | ||
| exists(string elem | | ||
| // it is more efficient to not create a capture group for the suffix, since | ||
| // `regexpCapture` will then always join in both groups, only to afterwards filter | ||
| // based on the requested group (the group number is not part of the binding set | ||
| // of `regexpCapture`) | ||
| elem = this.regexpCapture("^([0-9]+)\\..*$", 1) and | ||
|
Comment on lines
+122
to
+126
|
||
| e = decode(elem) and | ||
| suffix = this.suffix(elem.length() + 1) | ||
| ) | ||
| } | ||
|
|
||
| /** Holds if this list starts with `prefix`, followed by `e`. */ | ||
| bindingset[this] | ||
| predicate isSnoc(UnboundList prefix, Element e) { | ||
| exists(string regexp | regexp = "^(|.+\\.)([0-9]+)\\.$" | | ||
| prefix = this.regexpCapture(regexp, 1) and | ||
| e = decode(this.regexpCapture(regexp, 2)) | ||
| ) | ||
| // same remark as above about not using multiple capture groups | ||
| prefix = this.regexpCapture("^(|.+\\.)[0-9]+\\.$", 1) and | ||
| e = decode(this.substring(prefix.stringLength(), this.stringLength() - 1)) | ||
| } | ||
|
|
||
| /** Gets the head of this list, if any. */ | ||
|
|
||
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.
Is this saying that each call to
regexpCapturewould produce both capture groups and in the first call the second capture group would be thrown away and vice versa for the second call? Or something else?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.
Yes. Here is a simple example
which generates the following RA:
The workaround
with just a single capture group performs better: