Skip to content

Conversation

@jvantuyl
Copy link

@jvantuyl jvantuyl commented Aug 14, 2024

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).

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant