Hello, I just had an idea to optimize the size of ...
# coroutines
l
Hello, I just had an idea to optimize the size of binaries using coroutines even further by reusing
ContinuationImpl
classes whenever possible. What do you think? Details here: https://youtrack.jetbrains.com/issue/KT-39644
👀 2
h
Definitely interesting and I follow your logic. Hopefully it leads to something new
w
Do I understand correctly that the compiler would generate a shared
ContinuationImpl
for each combination of fields that right now the anonymous class has, eg.
Copy code
// $FF: synthetic field
Object result;
int label;
Object L$0;
?
e
Great idea, very hard to implement in practice.
Each coroutine impl also has a call to the underlying method, which has to be different for each instance.
l
Yes, I was thinking about a switch for these, taking the needed parameters in the needed order. That implies the "continuation implementation signature" orders the "keys", but that the needed order is kept right for calls to the underlying method. Should I edit the YouTrack ticket to make this more clear?
@wasyl I didn't quite understand your example, but I think you got it, it'd share the
ContinuationImpl
classes for compatible usages.
👍 1