Thread: inline functions

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    731

    inline functions

    I have a function that I have inlined. The only purpose of this function is so that I don't have to go thru each .h file and replace the section of code evertime I change somthing little.

    The function looks like this:

    Code:
    inline void args(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp);
    Now my question is, sence it is inline will take longer than if I did this:

    Code:
    Args args = {hwnd};
    sence that is only taking one variable I think that would be faster than the inline, but would it still be worth using the inline?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    One is a function, the other is a variable.
    Your question doesn't make any sense.

  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    ok ahh let me try and re-explain.

    The inline function will do:

    Code:
    Args args = {hwnd};
    and that is also the line of code the function is replacing.

    But I was wondering if the inline would be worth it or if it would impact speed.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    inline is one of those premature optimisations which is best avoided until you've finished the code and then have a chance to properly profile the code and make measured changes to the code to improve it.

    inline will
    - usually make the executable code bigger, but not always
    - usually make the code faster, but not always

    Single statement 'set' and 'get' functions inside classes are usually OK done as inline functions, but I'd be cautious of applying it early to any other kind of function.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inline Definitions and Declarations?
    By legit in forum C++ Programming
    Replies: 1
    Last Post: 06-15-2009, 01:59 PM
  2. Is it legal to have functions within functions?
    By Programmer_P in forum C++ Programming
    Replies: 13
    Last Post: 05-25-2009, 11:21 PM
  3. When to inline your *tors
    By Angus in forum C++ Programming
    Replies: 43
    Last Post: 10-29-2008, 03:38 PM
  4. conditional breakpoints and inline functions
    By Mario F. in forum C++ Programming
    Replies: 2
    Last Post: 08-10-2006, 08:30 PM
  5. inline friend functions.
    By sean in forum C++ Programming
    Replies: 2
    Last Post: 01-03-2002, 12:37 PM