Back to index

lightning-sunbird  0.9+nobinonly
SizeTest03.cpp
Go to the documentation of this file.
00001 // Test03.cpp
00002 
00003 #include "nsIDOMNode.h"
00004 #include "nsCOMPtr.h"
00005 #include "nsString.h"
00006 
00007 #ifdef __MWERKS__
00008        #pragma exceptions off
00009 #endif
00010 
00011 NS_DEF_PTR(nsIDOMNode);
00012 
00013        /*
00014               Windows:
00015                      nsCOMPtr_optimized*                                                                         45
00016                      raw_optimized                                                                                             48
00017                      nsCOMPtr_optimized                                                                          50
00018                      nsCOMPtr                                                                                                                54
00019                      nsCOMPtr*                                                                                                               59
00020                      raw                                                                                                                                   62
00021 
00022               Macintosh:
00023                      nsCOMPtr_optimized          112                                (1.0000)
00024                      raw_optimized                             124 bytes            (1.1071)      i.e., 10.71% bigger than nsCOMPtr_optimized
00025                      nsCOMPtr                                                144                                (1.2857)
00026        */
00027 
00028 void // nsresult
00029 Test03_raw( nsIDOMNode* aDOMNode, nsString* aResult )
00030               // m140, w62
00031        {
00032 // -- the following code is assumed, but is commented out so we compare only
00033 //             the relevent generated code
00034 
00035 //            if ( !aDOMNode || !aResult )
00036 //                   return NS_ERROR_NULL_POINTER;
00037 
00038               nsIDOMNode* parent = 0;
00039               nsresult status = aDOMNode->GetParentNode(&parent);
00040               
00041               if ( NS_SUCCEEDED(status) )
00042                      {
00043                             parent->GetNodeName(*aResult);
00044                      }
00045 
00046               NS_IF_RELEASE(parent);
00047 
00048 //            return status;
00049        }
00050 
00051 
00052 void // nsresult
00053 Test03_raw_optimized( nsIDOMNode* aDOMNode, nsString* aResult )
00054               // m124, w48
00055        {
00056 //            if ( !aDOMNode || !aResult )
00057 //                   return NS_ERROR_NULL_POINTER;
00058 
00059               nsIDOMNode* parent;
00060               nsresult status = aDOMNode->GetParentNode(&parent);
00061               
00062               if ( NS_SUCCEEDED(status) )
00063                      {
00064                             parent->GetNodeName(*aResult);
00065                             NS_RELEASE(parent);
00066                      }
00067 
00068 //            return status;
00069        }
00070 
00071 
00072 void // nsresult
00073 Test03_nsCOMPtr( nsIDOMNode* aDOMNode, nsString* aResult )
00074               // m144, w54/59
00075        {
00076 //            if ( !aDOMNode || !aResult )
00077 //                   return NS_ERROR_NULL_POINTER;
00078 
00079               nsCOMPtr<nsIDOMNode> parent;
00080               nsresult status = aDOMNode->GetParentNode( getter_AddRefs(parent) );
00081               if ( parent )
00082                      parent->GetNodeName(*aResult);
00083 
00084 //            return status;
00085        }
00086 
00087 void // nsresult
00088 Test03_nsCOMPtr_optimized( nsIDOMNode* aDOMNode, nsString* aResult )
00089               // m112, w50/45
00090        {
00091 //            if ( !aDOMNode || !aResult )
00092 //                   return NS_ERROR_NULL_POINTER;
00093 
00094               nsIDOMNode* temp;
00095               nsresult status = aDOMNode->GetParentNode(&temp);
00096               nsCOMPtr<nsIDOMNode> parent( dont_AddRef(temp) );
00097               if ( parent )
00098                      parent->GetNodeName(*aResult);
00099 
00100 //            return status;
00101        }