parsingdata / metal

A Java library for parsing binary data formats, using declarative descriptions.
Apache License 2.0
18 stars 9 forks source link

Using scope makes ref inefficient #381

Closed mvanaken closed 8 months ago

mvanaken commented 1 year ago

In order to find the requested scope it first finds all the scopes and then selects the correct scope from that list. If we then call for ref it would then traverse that scoped graph twice.

This can be made more efficient if we keep track of the scope while requesting the values with ref, similar as the limit parameter in Ref.

In fact, scope is only used in combination with Ref, because it would not make sense in any other context. It would therefor make much more sense if scope is a parameter for Ref. For example, a scoped Ref could look something like: last(ref("name", NO_LIMIT, con(0))

Since Ref already has a parameter for the limit (which is 1 in case of last), we should think about how to define the shorthand for a scoped ref.