-
Notifications
You must be signed in to change notification settings - Fork 425
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
Lazy look_ahead #1212
Lazy look_ahead #1212
Conversation
44813c8
to
faaa987
Compare
I know the change looks large, I made it so because I essentially see it as a rewrite. I would like to get some indication on whether you would accept a change along these lines. If you are positive, I'll finish up the PR, overwrite the existing implementation and update the integration tests. I've finished this locally. |
@audunhalland I'll take a look in a week or so. |
@tyranron Thanks! If you instead prefer a PR closer to the finished product, I can fix that before that time. |
fec8dc2
to
4a358fd
Compare
4a358fd
to
6517874
Compare
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.
@audunhalland the overall redesign looks interesting, and I'm much in favor to lazify things. Moreover, I'd like having it for the upcoming 0.16 release, so its benefirs could be described in the Book.
However, some API decisions should be thought, discussed and bikeshedded a little bit more, as I don't have strong opinion about them yet.
7bb1073
to
fc90071
Compare
@audunhalland once you finish adjustments, please, re-request my review via this GitHub button. Thanks! |
* No need to wrap a &[T] in an Option only because a Default impl is needed * Make more things module-private * `S: 'a` bound not needed
* make fn arguments() return impl Iterator<Item = LookAheadArgument> * re-introduce has_arguments() * remove struct LookAheadArguments (which was just an Iterator)
Iterators live in `pub mod iter`, an attempt to not clutter the look_ahead documentation page too much.
Ok, rebased on master, overwrote edit: I think the changelog should also be updated, maybe just use the change summary in the PR description? |
9669fda
to
6b31f12
Compare
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.
@audunhalland thank you for the hard work on this!
I've noticed that when using the look-ahead feature, this always involves a full traverse/transform of the input document under that node. This can be a problem when the input documents are large and complex.
This is an attempt to rewrite the
look_ahead
API so that its invocation becomes basically free. Instead of doing a forced deep transformation up front, the required work has been moved into the methods explicitly called by the API user.A single level of
LookAheadChildren
gets computed when the user callsLookAheadSelection::children()
.The arguments/values to a field are also lazily computed, and variable substitution is now done purely on demand.
The PR is in a draft state and the old
look_ahead
API is still intact for the time being, I'm interested in general feedback first before finishing it off.Summary of API breakages:
trait LookAheadMethods
removed. In my opinion there's no need for this and it always requires an explicit extra import.struct ConcreteLookAheadSelection
removedstruct LookAheadArguments
removed, replaced by an opaqueimpl Iterator
struct LookAheadSelection
now has some inherent methods at least partially compatible withLookAheadMethods
:field_name
,has_arguments
: Compatible signaturearguments
now returnsimpl Iterator<Item = LookAheadArgument>
instead of&[LookAheadArgument]
.argument
now returnsOption<LookAheadArgument>
instead ofOption<&LookAheadArgument>
.children
now returnsLookAheadChildren
instead ofVec<&Self>
.LookAheadChildren
implementsIntoIterator
.field_original_name
/field_alias
: New in0.16
LookAheadChildren
:LookAheadMethods::child_names
LookAheadMethods::has_children
moved toLookAheadChildren::is_empty
LookAheadMethods::select_child
moved toLookAheadChildren::select
LookAheadSelection::for_explicit_type
moved toLookAheadSelection::children_for_explicit_type
, which returnsLookAheadChildren
.LookAheadValue::List(_)
contains a new structLookAheadList
withIntoIterator
+iter
method.LookAheadValue::Object(_)
contains a new structLookAheadObject
withIntoIterator
+iter
method.