fix inline table and array transforms#41
Open
jvantuyl wants to merge 3 commits intobitwalker:mainfrom
Open
Conversation
Also includes update to benchmark configuration needed by benchee update.
Previously the values for these weren't descended into. This prevented all of the transforms from being applied to them, including the key transforms.
This was referenced Aug 15, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 transform documentation states that a transform function will be invoked for "every key/value pair in the document, in a depth-first, bottom-up, traversal of the document." Even key transformation functions are implemented using a transform, so they're clearly expected to be comprehensive.
In handling a configuration file, I noticed that inline tables weren't getting my transformer run. Upon closer inspection, I noticed the keys weren't being converted either. A little more investigation determined that this didn't work for inline arrays either.
I determined that the values for inline arrays and inline tables weren't being descended into (though the elements themselves were being "transformed"). This didn't meet the expectation that every key/value pair in the document was being transformed.
To fix this, I dug into the decoder and explicitly emitted tags for arrays and inline tables in the same way that table arrays were already handled. I then added complementary code to the document processing functions to properly transform these into lists and maps.
I paid special attention to ensure that transforms were applied both to the children of these constructs and to the constructs themselves. This seemed to match the expectation of the existing transform tests and made sense.
All tests pass and all benchmarks show nominal speed impact (less than 1%, at worst about 20 microseconds in one test run).