inline command

Started by
41 comments, last by CProgrammer 20 years, 7 months ago
yeah, ''inline'' as well as ''register'' are just suggestions. there is no guarantee that it will happen.

also, don''t try to inline a function that uses a for loop (or any loop for that matter). You''re compiler will shit a break, which if you are wondering, is not a good thing.

Do you use your powers for good or for awesome?
|My site | Association of Computing Machinery

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

Advertisement
In loops. Don''t use it if a functioncall is just used once.

.lick
quote:Original post by Pipo DeClown
Don''t use it if a functioncall is just used once.

That''s not really correct, I''m afraid.

[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || MSVC++ Library Fixes || BarrysWorld || E-Mail Me ]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]
Interesting...

What MSDN says about inline
captn_midnight, can you elaborate on the loop thing, why exactly would that cause a problem? what is this break you talk about? ... i use loops in linine functions quite a lot
Don''t try to make evry functions inline ! i had bugs in Win32 debug mode when my library was entirely inlined !
You just need to know how they work, and how and when to use them effectively. Click here for a simple page providing you with the basic ideas.

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

[edited by - Lektrix on September 3, 2003 7:45:18 AM]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]
quote:Original post by CProgrammer
When is it generally good to use the inline command?

1. Don''t.
2. (For experts) Not yet.
3. If you really want to, profile first, and look try it for yourself. You can get some marginal gains that way.
quote:In my opinion, the inline mechanism is of great importance in the support of encapsulation/information hiding and the design of abstract data types

How do you support that opinion? What you wrote doesn''t make sense to me, but I don''t know you...

Cédric
quote:Original post by marijnh
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.


That''s actually wrong. An inline function will almost invariably increase the size of code. Let''s say the function for multiply takes 7 instructions, and x*y takes 3 instructions (register, mul, store). That means if you put "x*y" in your code 4 times it will take 12 instructions, while if you had used it as a function call takes only 7+3 instructions = 10.

As a side note I feel its generally just about useless to manually inline functions with modern compilers. Optimize for speed and your compiler will generally inline where appropriate. Its just a hint anyways. Profile the compiler optimized code and if it appears that you''re bottle necking from code that could be inlined then see if it helps, otherwise inlining adds significant mess to code and will often provide negligable if any speed.
quote:Original post by Lektrix
quote:Original post by Pipo DeClown
Don''t use it if a functioncall is just used once.

That''s not really correct, I''m afraid.

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


K whatever. Bluh =P Hehehe.. I think I meant the opposite.. did I.. ?

.lick

This topic is closed to new replies.

Advertisement