Allow direct struct field matching from binary token #127
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The binary token resolution leaves some efficiency on the table as it first translates the token to a string and then matches the string against struct fields.
The PR asks the question, what if we reduce the operation to just matching on the 16bit value? Remove the translation step and simplify matching.
This is what I envision and technically now works in this PR:
Large caveats:
classify each struct if fields can be directly resolved or if it needs translation based on the presence of the
#[jomini(token)]
attribute.For direct structs, swap the request to
deserialize_identifier
todeserialize_u16
to give a hint that tokens should not be resolved.Some unanswered questions: