softwaremill / magnolia

Easy, fast, transparent generic derivation of typeclass instances
https://softwaremill.com/open-source/
Apache License 2.0
754 stars 116 forks source link

Split subtypes array initialization to multiple functions. #485

Closed nox213 closed 11 months ago

nox213 commented 11 months ago

We are using Magnolia in production and mainly use it to derive the parent type's type class instances from the type class instances of subtypes. One of our types has more than 700 subtypes, and when derives typeclass instances of this type, the process of initializing the huge subtypes array is performed in a single method, resulting in a "Method too large" compilation error. This PR splits the initialization of the subtypes array into multiple functions and calls each function at the end to combine the array. This method also increases the size of the method, but to a much slower degree, so I think it's still worthwhile. I would appreciate it if you could review it.

nox213 commented 11 months ago

@joroKr21 I fixed based on what you commented. Could you review this PR again?

adamw commented 11 months ago

Thanks! Release is in progress