void glen(int a, int b)
{
if (a == 10)
{
switch(b)
{
case 1: .
:
case 20: puts("b is 20");
break;
case 30: .
:
default: .
:
}
}
}
and assuming your program calls glen several times with constant arguments, for example, glen(10, 20);, each call to glen causes the if and switch expressions to be evaluated. If glen is inlined, the compiler can then optimize the function. The evaluation of the if and switch statements can be done at compile time, and the function code can then be reduced to only the puts statement from case 20.
![]()
Restrictions on Inlining
Benefits and Drawbacks of Inlining