Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Do not use lambdas in Converters #1249

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

radcortez
Copy link
Member

No description provided.

@dmlloyd
Copy link
Contributor

dmlloyd commented Nov 11, 2024

Why? Is there some kind of problem case?

@radcortez
Copy link
Member Author

I did notice some extra allocs in the flamegraph.

@dmlloyd
Copy link
Contributor

dmlloyd commented Nov 11, 2024

I would expect a similar number of allocations in either case. The only difference would be the one time initialization of the lambda infrastructure, but that gets paid by someone at some point no matter what so there's no reason to avoid it here IMO.

@franz1981
Copy link
Contributor

It's considered a bit nuts, but you can even decide to have a single Object converter which have a switch based on an enum filed which represent the actual type and perform the right behaviour.
It will allow to have N instances of the same converter class.
Not saying you should do it eh, but if you don't want to trade lambdas dynamic gen vs class loading for N anon types, you can decide to do it.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants