Back to index

lightning-sunbird  0.9+nobinonly
Functions
SizeTest01.cpp File Reference
#include "nsIDOMNode.h"
#include "nsCOMPtr.h"
#include "nsString.h"

Go to the source code of this file.

Functions

 NS_DEF_PTR (nsIDOMNode)
void Test01_raw (nsIDOMNode *aDOMNode, nsString *aResult)
void Test01_raw_optimized (nsIDOMNode *aDOMNode, nsString *aResult)
void Test01_nsCOMPtr (nsIDOMNode *aDOMNode, nsString *aResult)
void Test01_nsCOMPtr_optimized (nsIDOMNode *aDOMNode, nsString *aResult)

Function Documentation

void Test01_nsCOMPtr ( nsIDOMNode aDOMNode,
nsString aResult 
)

Definition at line 89 of file SizeTest01.cpp.

       {
              nsCOMPtr<nsIDOMNode> node = aDOMNode;

              if ( node )
                     node->GetNodeName(*aResult);
       }
void Test01_nsCOMPtr_optimized ( nsIDOMNode aDOMNode,
nsString aResult 
)

Definition at line 99 of file SizeTest01.cpp.

       {
//            if ( !aDOMNode )
//                   return;

              nsCOMPtr<nsIDOMNode> node = aDOMNode;
              node->GetNodeName(*aResult);
       }
void Test01_raw ( nsIDOMNode aDOMNode,
nsString aResult 
)

Definition at line 43 of file SizeTest01.cpp.

       {
                     /*
                            This test is designed to be more like a typical large function where,
                            because you are working with several resources, you don't just return when
                            one of them is |NULL|.  Similarly: |Test01_nsCOMPtr00|, and |Test01_nsIPtr00|.
                     */

              nsIDOMNode* node = aDOMNode;
              NS_IF_ADDREF(node);

              if ( node )
                     node->GetNodeName(*aResult);

              NS_IF_RELEASE(node);
       }
void Test01_raw_optimized ( nsIDOMNode aDOMNode,
nsString aResult 
)

Definition at line 62 of file SizeTest01.cpp.

       {
                     /*
                            This test simulates smaller functions where you _do_ just return
                            |NULL| at the first sign of trouble.  Similarly: |Test01_nsCOMPtr01|,
                            and |Test01_nsIPtr01|.
                     */

                     /*
                            This test produces smaller code that |Test01_raw| because it avoids
                            the three tests: |NS_IF_...|, and |if ( node )|.
                     */

// -- the following code is assumed, but is commented out so we compare only
//             the relevent generated code

//            if ( !aDOMNode )
//                   return;

              nsIDOMNode* node = aDOMNode;
              NS_ADDREF(node);
              node->GetNodeName(*aResult);
              NS_RELEASE(node);
       }

Here is the call graph for this function: