title: Is it more efficient to call functions or fill control if statements with local variables rather than directly nesting a function call?
body: <p>In C++, does it produce a faster executable if you supply the data to be compared within the brackets of an <code>if</code> statement as the implicit result of a nested function instead of a separate local variable?  In the same way, is it more efficient to provide an argument to a function as the result of a nested function called, again instead of a separate local variable?</p>
  
  <p>What I mean is:</p>
  
  <pre><code>int comparison=0;
  char *name=nullptr;
  
  GetNameFromRegistry(queried_name);  //Unillustrated function that retrieves a name
                                      //entry from the Windows registry, dynamically
                                      //allocates a sufficiently-sized chunk of memory
                                      //to hold it and null-terminates the string.
  
  comparison=strcmp(queried_name,"Fred");
  
  if(comparison==0){
      MessageBox(NULL,
          "We have found Fred.",
          "Name Search", 
          MB_OK | MB_ICONINFORMATION);
  }
  </code></pre>
  
  <p>as opposed to:</p>
  
  <pre><code>char *queried_name=nullptr;
  
  GetNameFromRegistry(queried_name);  //Unillustrated function that retrieves a name
                                      //entry from the Windows registry, dynamically
                                      //allocates sufficiently-sized chunk of memory
                                      //to hold it and null-terminates the string.
  
  
  if(strcmp(queried_name, "Fred")==0){
      MessageBox(NULL,
          "We have found Fred.",
          "Name Search",
          MB_OK | MB_ICONINFORMATION);
  }
  </code></pre>
  
  <p>Another example:</p>
  
  <pre><code>CData gp_data;  //CData is a class that holds values, arrays and
                  //volatile/non-volatilve data for a windows application, 
                  //saving those non-volatile values to the registry to be
                  //retrieved the next time it is launched.
  
  SendMessage(dialog,
      WM_SETICON,
      reinterpret_cast&lt;WPARAM&gt;(ICON_SMALL),
      reinterpret_cast&lt;LPARAM&gt;(gp_data-&gt;Get_Small_Application_Icon()));
  </code></pre>
  
  <p>as opposed to:</p>
  
  <pre><code>HICON small_icon=0;
  CData gp_data;  //CData is a class with holds values, arrays and volatile data for
                  //a windows application, saving non-volatile values to the registry
                  //to use the next time it is launched.
  
  small_icon=gp_data-&gt;Get_Small_Application_Icon();
  
  SendMessage(dialog,
      WM_SETICON,
      reinterpret_cast&lt;WPARAM&gt;(ICON_SMALL),
      reinterpret_cast&lt;LPARAM&gt;(small_icon));
  </code></pre>
  
  <p>Obviously in the first example, the first form requires an extra local variable be allocated from the stack, but I personally think it is easier to read/debug.</p>
  
  <p>Again, in the second example an extra local variable is required, which once more I think is easier to read.  However, perhaps there are performance gains to be had from the first form that compensate for a loss in readability?</p>