-
Notifications
You must be signed in to change notification settings - Fork 49
Overhaul quantification optimizations #710
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
Refactors mutating methods into string methods for easier unit testing and parity-checking via assertions. Prepares for more efficient implementations.
|
@swift-ci please test |
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.
Just a few questions, otherwise looks good!
@@ -603,9 +602,9 @@ extension AST.Atom.CharacterProperty { | |||
if p(input, bounds) != nil { return nil } | |||
|
|||
// TODO: bounds check |
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.
What's the story here — does the bounds check always happen before the consume function is called? Or is there a post-advancement check to make sure we haven't gone beyond the bounds of the search range?
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.
This doesn't change the behavior. Let's open an issue for that
limitedBy end: Index, | ||
anyMatchesNewline: Bool, | ||
isScalarSemantics: Bool | ||
) -> Index? { |
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.
Are we still making distinctions between the .
literal syntax and other "any" designations at this point in the engine? For example, CharacterClass.any
and CharacterClass.anyNonNewline
are unaffected by the (?s)
option, and always do what they say they should. I thought that we had already handled those distinctions during code gen (e.g. by calling emitAny
vs emitAnyNonNewline
).
If this method is just for the .
literal, does it need to account for the NSRE-compatible-dot mode? In that case, a full \r\n
pair needs to be consumed even when using scalar semantics.
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.
This is the leaf function which provides the implementation. The anyMatchesNewline
parameter dictates what the behavior is, and is at least part of the quantification payload.
signalFailure() | ||
return false | ||
} | ||
if let savePointRange { |
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.
assert(!produceSavePointRange)
here would make sure we don't accidentally return a save point range when instructed not to.
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.
@Catfish-Man could you take over and see about that assertion?
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.
Once I figure out my build issues, yup :)
|
||
while true { | ||
if maxExtraTrips == 0 { break } | ||
return (currentPosition, rangeStart..<rangeEnd) |
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.
With the assertion above, should this be Range(uncheckedBounds:)
instead of ..<
?
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, that would work.
Supersedes #706