inline command

Started by
41 comments, last by CProgrammer 20 years, 7 months ago
When is it generally good to use the inline command? -CProgrammer
Advertisement
well, as ever: this depends on...

but in general, usage of inline functions is often good when calling small functions much times.





DJSnow
---
this post is manually created and therefore legally valid without a signature
DJSnow---this post is manually created and therefore legally valid without a signature
Hey thanks

-CProgrammer
Inline creates speed and creates code bloat. But like he said, for small, often-called routines it''s alright.
http://edropple.com
It is said to make the execution of a program faster... but in my case my code executes fast enough that I don''t think I have any inline functions... or maybe I do!
I load code! It's my whole philosophy!
Actually, for functions with really tiny bodies like
inline int multiply(int x, int y){
return x*y;
}
...inline functions *decrease* executable size. Placing x*y directly in the executable is much smaller calling a function. Just be careful with calling inline function from inline functions from inline functions...
I''ve always wondered what the compiler does if you create a recursive inline function... but i guess it is always free to create a normal function even if you specify ''inline''.
Basically if you have to do it a LOT, because it reduces overhead. In practice, you''re usually going to be putting your Gets and Sets as inlines, and maybe the occassional short operation. The main argument against inlines has historically been that compilers like MSVC6 couldn''t handle stepping into inlines, but I think they fixed that in 7.

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
There''s sometimes a compiler option that leaves this question for the compiler to decide. Sometimes if the code gets bigger you get more cache misses which slows things down. I think there''s alot of things that should be done before forcing inline.
quote:Original post by felisandria
Basically if you have to do it a LOT, because it reduces overhead. In practice, you''re usually going to be putting your Gets and Sets as inlines, and maybe the occassional short operation. The main argument against inlines has historically been that compilers like MSVC6 couldn''t handle stepping into inlines, but I think they fixed that in 7.

-fel


All of my code is said to be non-inline.


I load code! It''s my whole philosophy!
I load code! It's my whole philosophy!
quote:Original post by marijnh
I've always wondered what the compiler does if you create a recursive inline function... but i guess it is always free to create a normal function even if you specify 'inline'.

As far as I know, the compiler will ignore your 'recommendation' to inline it, as it is not possible/allowed.

In my opinion, the inline mechanism is of great importance in the support of encapsulation/information hiding and the design of abstract data types.

quote:It is said to make the execution of a program faster... but in my case my code executes fast enough that I don't think I have any inline functions... or maybe I do!

All of my code is said to be non-inline.

Oh, dear...

[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || MSVC++ Library Fixes || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on September 2, 2003 3:43:29 PM]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]

This topic is closed to new replies.

Advertisement