Closed audunhalland closed 10 months ago
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.
@audunhalland once you finish adjustments, please, re-request my review via this GitHub button. Thanks!
Ok, rebased on master, overwrote look_ahead
and updated the tests I found to be relevant (based on grepping for look_ahead
).
edit: I think the changelog should also be updated, maybe just use the change summary in the PR description?
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.