Skip to content

Skip transform_values when dealing with a Dry::Struct#202

Merged
katafrakt merged 1 commit intomainfrom
improve-dry-struct-hashifying
Feb 28, 2026
Merged

Skip transform_values when dealing with a Dry::Struct#202
katafrakt merged 1 commit intomainfrom
improve-dry-struct-hashifying

Conversation

@katafrakt
Copy link
Copy Markdown
Contributor

This brings performance improvements of around 1.4-1.9x according to my benchmarks. Hashify.[] is already part of the implementation of .to_h for a Dry::Struct. Fixes #200. I used an example from that ticket for benchmarks.

Also makes it explicit that we are checking here for a Dry::Struct, not a Struct from stdlib. And fixes the YARD doc.

Copy link
Copy Markdown
Member

@timriley timriley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @katafrakt! Looks good, let's merge this in. Please add a CHANGELOG entry, I'll cut a patch release soon :)

This brings performance improvements of around 1.4-1.9x according to my
benchmarks. `Hashify.[]` is already part of the implementation of
`.to_h` for a `Dry::Struct`.

Also makes it explocit that we are checking here for a `Dry::Struct`,
not a `Struct` from stdlib.
@katafrakt katafrakt force-pushed the improve-dry-struct-hashifying branch from 8c34d08 to 7425fd2 Compare February 28, 2026 08:00
@katafrakt katafrakt merged commit 24e6869 into main Feb 28, 2026
8 checks passed
@katafrakt katafrakt deleted the improve-dry-struct-hashifying branch February 28, 2026 08:06
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.

Hashify / transform_values is unnecessarily being called for nested Dry::Structs

2 participants