thomas said:
any other reason except that inline inserts code directly to the
caller while function call push parameters to the stack (which is time
consuming)?
Uh... Yes, "time consuming" usually means "slower". Is this a trick
question? If you compare the code generated to call a function versus
to perform the same operations without calling a function, you will
notice that the function calling code contains extra instructions, to
execute which the CPU is bound to spend more time. Among those
instructions are, as you mentioned, the copying of arguments where they
are supposed to go (stack, registers), extracting them from that place
once inside the function body, general preserving of some CPU registers,
restoring them afterwards, and so on. Often with stack-based argument
passing, functions in the beginning contain code to check the stack size
or even integrity, which also uses up some time... If the body of the
function is available to the compiler, the compiler can optimize more
aggressively, thus saving more time. Probably there are other things,
although we're already too far into hardware-specific area...
V