17 Jul, 2007, Omega wrote in the 1st comment:
Votes: 0
In general, if you are sure that a function will never be called from another module, it should be declared as 'static'. This has two effects:

a) smaller code size (no out-of-line version retained in image), and
b) a simpler debug view (no out-of-line version to display)

I stumbled across this while looking up ways to optimize my code, and I figured I'd share it, as I'm quite sure most people
don't do this. As I've seen allot of peoples released muds, and I was wondering if this has any merit to it. Because hell,
if I'm going todo something like this, then I'm going to want to know if it works first. So, if anyone has any experience with this
or any examples, i'd love to see them.

Second Off: Inlining:

The inline keyword is an extremely simple and powerful means of optimizing C++ programs. In one oft-cited case, the C++ standard library sort ran 7 times faster than qsort on a test of 500,000 elements because the C++ version was inlined. On the other hand, inline functions are also overused, and the consequences are significant. Inline indicates to the compiler that a function may be considered for inline expansion. If the compiler chooses to inline a function, the function is not called, but copied into place. The performance gain comes in avoiding the function call, stack frame manipulation, and the function return. The gains can be considerable.

Beware! Inline functions are not free. They can increase program size. They can increase execution time by reducing the caller's locality of reference. When sizes increase, the caller's inner loop may no longer fit in the processor cache, causing unnecessary cache misses and the consequent performance hit. Inline functions also increase build times - if inline functions change, the world must be recompiled. Some guidelines:

Avoid inlining functions until profiling indicates which functions could benefit from inline.
Consider using your compiler's option for auto-inlining after profiling both with and without auto-inlining.
Only inline functions where the function call overhead is large relative to the function's code. In other words, inlining large functions or functions that call other (possibly inlined) functions is not a good idea.

Is this all true, I know inlining puts the function right into the other function, and increases file-size, but has anyone ever noticed
any significant difference in their code by using inlining.

And what effect would a static inline <function> do ? would it be a faster processing uber function from hell that bloats your file-size?
or would it just be a moot point. The information on static inlines was confusing at best when you look at the information about the use of static and inline by themselves.

in anycase, if someone can answer all of those questions I'd be quite the happy man as I trek forth into trying to become better at my coding and optimizing of said code.

Thanks :)
0.0/1