A step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.
A C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.
This tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.
Creating a Rich Text Editor using JavaScript is easier to do than you might think, thanks to the support of modern browsers; this tutorial will walk you through it.
Inline functionsExplains the need of inline functions, when to / not to use them and how to use them. |
On Saturday, September 25th 2004 at 01:28 PM By Andrew Pociu (View Profile) ![]() ![]() ![]() ![]() (Rated 2.9 with 31 votes) |
||
|
In this tutorial I'll explain what inline functions are and after that I'll show you an example of using inline functions. If you don't know yet, when in your code there's a function, the program jumps to the address of the function and when it reaches the end of the function it comes back. This 'jumping' actually involves much more (copying the arguments of the function on the stack for example) and takes time. The solution is inline functions. Where an inline function is called the compiler will replace the call with the function code. So in reality in that place there will be no function call, only the code of the function. No 'jumping' needed to different addresses, no fuss. But now you may ask... When should I use inline functions?You have to be careful when to use inline functions and when not. Most of the time you won't need to use inline functions as the performance gain is small. The question actually is: When shouldn't I use inline functions? The answer to this question is also inexact. You should think about what using an inline function involves in some situations. For example you shouldn't use inline functions when the function is called several times as this is a waste of space (think of 8 function calls, 8 copies of that function in the code). Sometimes the compiler doesn't care about your decision, if you want the function to be inline or not. If the compiler sees that you want to make a huge function inline it may not respect your decision. Also, there are cases in which some small functions are treated as inline by some compilers. How do I use inline functions?The following code creates and calls an inline function:
Besides adding the keyword inline before the function, you also have to place the function above any other function that may call this one. This also excludes the posibility of making recursive functions (functions that call each other) inline. |
|||
Digg It!
Del.icio.us
Reddit
StumbleIt
Newsvine
Furl
BlinkList
|
|||
|
|||
Current Commentsok
This tutorial is best for student
Its very easy to learn inline function
thanks......
Related Tutorials
Related Source Code
C++ Job Search