-
Notifications
You must be signed in to change notification settings - Fork 49
Obtain match output elements without materializing the output. #469
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
@swift-ci please test |
36cbe78
to
59e77ba
Compare
@swift-ci please test |
@swift-ci please test |
func sizeAndAlignMask<T>(_: T.Type) -> (Int, Int) { | ||
(MemoryLayout<T>.size, MemoryLayout<T>.alignment - 1) | ||
} | ||
// The ABI of an offset-based key path only stores the byte offset, so |
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.
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.
rdar://63819465
@swift-ci please test |
output[keyPath: keyPath] | ||
// Note: We should be able to get the element offset from the key path | ||
// itself even at compile time. We need a better way of doing this. | ||
guard let outputTupleOffset = MemoryLayout.tupleElementIndex( |
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.
When we store the whole match inside the capture list, we will be able to precompute these offsets for all elements in a Regex.Match
. I'll do that next.
@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.
It might be useful to write tests where a capture transform produces a Substring
by e.g. returning .dropFirst()
. Similarly for when that capture-transform appears inside an Optionally
or is adding or removing a layer of Substring optionality.
) | ||
return typeErasedMatch as! Output | ||
} | ||
} | ||
|
||
var wholeMatchType: Any.Type { | ||
value.map { type(of: $0) } ?? Substring.self |
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 if it's optional? Also, are we tracking nested optionals correctly here (I.e. do they get turned into values or are they counted)?
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.
When there's no dedicated value for whole match, it can only be a Substring
.
@swift-ci please test |
Obtain match output elements without materializing the output.
Resolves #267.