Tail Sharing |
|
Handlers in a dispatch loop often share common code sequences (tails) that run through to the end of the handlers. Therefore: | |
Write such common sequences once and let subsquent handlers jump into the sequence at the point of initial commonality. | |
An alternative would be to factor common sequences into shared subroutines.
Tail sharing avoids the expense of subroutine linkage when the subroutine
would always eventually return to the same place.
Contrast with Tail Recursion in which an apparently recursive call can be replaced by looping. |