xpcom/tests/SizeTest03.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/tests/SizeTest03.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,97 @@
     1.4 +// Test03.cpp
     1.5 +
     1.6 +#include "nsIDOMNode.h"
     1.7 +#include "nsCOMPtr.h"
     1.8 +#include "nsString.h"
     1.9 +
    1.10 +NS_DEF_PTR(nsIDOMNode);
    1.11 +
    1.12 +	/*
    1.13 +		Windows:
    1.14 +			nsCOMPtr_optimized*											 45
    1.15 +			raw_optimized														 48
    1.16 +			nsCOMPtr_optimized											 50
    1.17 +			nsCOMPtr																 54
    1.18 +			nsCOMPtr*																 59
    1.19 +			raw																			 62
    1.20 +
    1.21 +		Macintosh:
    1.22 +			nsCOMPtr_optimized		112					(1.0000)
    1.23 +			raw_optimized					124 bytes		(1.1071)	i.e., 10.71% bigger than nsCOMPtr_optimized
    1.24 +			nsCOMPtr							144					(1.2857)
    1.25 +	*/
    1.26 +
    1.27 +void // nsresult
    1.28 +Test03_raw( nsIDOMNode* aDOMNode, nsString* aResult )
    1.29 +		// m140, w62
    1.30 +	{
    1.31 +// -- the following code is assumed, but is commented out so we compare only
    1.32 +//		 the relevent generated code
    1.33 +
    1.34 +//		if ( !aDOMNode || !aResult )
    1.35 +//			return NS_ERROR_NULL_POINTER;
    1.36 +
    1.37 +		nsIDOMNode* parent = 0;
    1.38 +		nsresult status = aDOMNode->GetParentNode(&parent);
    1.39 +		
    1.40 +		if ( NS_SUCCEEDED(status) )
    1.41 +			{
    1.42 +				parent->GetNodeName(*aResult);
    1.43 +			}
    1.44 +
    1.45 +		NS_IF_RELEASE(parent);
    1.46 +
    1.47 +//		return status;
    1.48 +	}
    1.49 +
    1.50 +
    1.51 +void // nsresult
    1.52 +Test03_raw_optimized( nsIDOMNode* aDOMNode, nsString* aResult )
    1.53 +		// m124, w48
    1.54 +	{
    1.55 +//		if ( !aDOMNode || !aResult )
    1.56 +//			return NS_ERROR_NULL_POINTER;
    1.57 +
    1.58 +		nsIDOMNode* parent;
    1.59 +		nsresult status = aDOMNode->GetParentNode(&parent);
    1.60 +		
    1.61 +		if ( NS_SUCCEEDED(status) )
    1.62 +			{
    1.63 +				parent->GetNodeName(*aResult);
    1.64 +				NS_RELEASE(parent);
    1.65 +			}
    1.66 +
    1.67 +//		return status;
    1.68 +	}
    1.69 +
    1.70 +
    1.71 +void // nsresult
    1.72 +Test03_nsCOMPtr( nsIDOMNode* aDOMNode, nsString* aResult )
    1.73 +		// m144, w54/59
    1.74 +	{
    1.75 +//		if ( !aDOMNode || !aResult )
    1.76 +//			return NS_ERROR_NULL_POINTER;
    1.77 +
    1.78 +		nsCOMPtr<nsIDOMNode> parent;
    1.79 +		nsresult status = aDOMNode->GetParentNode( getter_AddRefs(parent) );
    1.80 +		if ( parent )
    1.81 +			parent->GetNodeName(*aResult);
    1.82 +
    1.83 +//		return status;
    1.84 +	}
    1.85 +
    1.86 +void // nsresult
    1.87 +Test03_nsCOMPtr_optimized( nsIDOMNode* aDOMNode, nsString* aResult )
    1.88 +		// m112, w50/45
    1.89 +	{
    1.90 +//		if ( !aDOMNode || !aResult )
    1.91 +//			return NS_ERROR_NULL_POINTER;
    1.92 +
    1.93 +		nsIDOMNode* temp;
    1.94 +		nsresult status = aDOMNode->GetParentNode(&temp);
    1.95 +		nsCOMPtr<nsIDOMNode> parent( dont_AddRef(temp) );
    1.96 +		if ( parent )
    1.97 +			parent->GetNodeName(*aResult);
    1.98 +
    1.99 +//		return status;
   1.100 +	}

mercurial