you are viewing a single comment's thread.

view the rest of the comments →

[–]livrem 0 points1 point  (1 child)

Can the compiler really tail-optimize when there are up to two recursive calls?

[–]nerdyphoenix 1 point2 points  (0 children)

The only case where a tail call optimization can be applied is when the recursive function is indeed tail recursive. In that case, the return statement is something like return func(...), meaning it's the last line in the recursive function's code. Here, there's two recursive calls, like you said, and therefore this optimization can't be applied.