Thread: What is more efficient?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    Quote Originally Posted by matsp View Post
    Agressive use of inlining can lead to increased code-size, yes. Letting the compiler inline when it feels it's right will probably not do this too bad. The -Os switch will only inline a function if the resulting code is smaller than the code with outlined functions - so only real tiny functions.
    Or if the function is nonrecursive and only called in one place. This can happen if parts of the code of a large function are moved out into "helper functions" solely to make it easier to understand and maintain.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by robatino View Post
    Or if the function is nonrecursive and only called in one place. This can happen if parts of the code of a large function are moved out into "helper functions" solely to make it easier to understand and maintain.
    True - and again, the code produced by this is actually smaller than if there was an external function - because parameter passing and call itself has been removed.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Most Efficient Way to Check a Variable Is A Whole Number
    By bengreenwood in forum C++ Programming
    Replies: 29
    Last Post: 05-28-2009, 01:33 PM
  2. Is std::map efficient for this problem?
    By dudeomanodude in forum C++ Programming
    Replies: 12
    Last Post: 04-10-2008, 02:15 PM
  3. Efficient Algorithm
    By purple in forum C Programming
    Replies: 10
    Last Post: 02-05-2003, 03:01 PM
  4. How do I write more efficient code?
    By minesweeper in forum C++ Programming
    Replies: 4
    Last Post: 08-06-2002, 11:08 AM
  5. Any better & efficient alternative to this C prg.
    By perlguy in forum C Programming
    Replies: 12
    Last Post: 05-24-2002, 03:00 AM