pyteal icon indicating copy to clipboard operation
pyteal copied to clipboard

Inline subroutines

Open jasonpaulos opened this issue 3 years ago • 1 comments

Summary

It would be a good optimization to identify subroutines that can be inlined directly into the caller code instead of being a legitimate subroutine. A common use case for subroutines is to increase readability, not necessarily because they are called frequently.

Scope

If a subroutine is only called from one place, it will always be more efficient to inline that subroutine into the caller code.

If a subroutine is called from multiple places, it might be more efficient to inline it if it's body is sufficiently small, but this is a more complex case to analyze, and likely less important. I only include it here for completeness--this issue should probably not address it.

jasonpaulos avatar Jan 27 '22 20:01 jasonpaulos

One question: when I reviewed all the previous tickets, I think the reason for introducing this ticket is for reducing scratch slot usage in subroutine pre version 8.

After introduction of frame pointer, this seems no longer a pressing problem in functionality, for no dependency of scratch slot in subroutine is strictly required any more.

What do yall think?

ahangsu avatar Dec 30 '22 23:12 ahangsu