Idea: Use Source Generators to rewrite LINQ expressions
Author: louthyCreated Oct 12, 2021Updated Oct 24, 2024
Labelsideav5
This has been going around my head for a while, I'm not sure if it's possible, but want to get it written down just in case.
Problem: LINQ expressions come with lambda allocation and contextual type allocation costs, this means their performance isn't as good as writing imperative code.
Possible solution: Use Source Generators to find LINQ expressions that evaluate to known language-ext monadic types. Replace the LINQ expression with an 'unrolled' version that runs imperatively. It won't remove all lambda usage, but would significantly reduce it.
Source: louthy/language-ext