xpcom/tests/SizeTest03.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 // Test03.cpp
     3 #include "nsIDOMNode.h"
     4 #include "nsCOMPtr.h"
     5 #include "nsString.h"
     7 NS_DEF_PTR(nsIDOMNode);
     9 	/*
    10 		Windows:
    11 			nsCOMPtr_optimized*											 45
    12 			raw_optimized														 48
    13 			nsCOMPtr_optimized											 50
    14 			nsCOMPtr																 54
    15 			nsCOMPtr*																 59
    16 			raw																			 62
    18 		Macintosh:
    19 			nsCOMPtr_optimized		112					(1.0000)
    20 			raw_optimized					124 bytes		(1.1071)	i.e., 10.71% bigger than nsCOMPtr_optimized
    21 			nsCOMPtr							144					(1.2857)
    22 	*/
    24 void // nsresult
    25 Test03_raw( nsIDOMNode* aDOMNode, nsString* aResult )
    26 		// m140, w62
    27 	{
    28 // -- the following code is assumed, but is commented out so we compare only
    29 //		 the relevent generated code
    31 //		if ( !aDOMNode || !aResult )
    32 //			return NS_ERROR_NULL_POINTER;
    34 		nsIDOMNode* parent = 0;
    35 		nsresult status = aDOMNode->GetParentNode(&parent);
    37 		if ( NS_SUCCEEDED(status) )
    38 			{
    39 				parent->GetNodeName(*aResult);
    40 			}
    42 		NS_IF_RELEASE(parent);
    44 //		return status;
    45 	}
    48 void // nsresult
    49 Test03_raw_optimized( nsIDOMNode* aDOMNode, nsString* aResult )
    50 		// m124, w48
    51 	{
    52 //		if ( !aDOMNode || !aResult )
    53 //			return NS_ERROR_NULL_POINTER;
    55 		nsIDOMNode* parent;
    56 		nsresult status = aDOMNode->GetParentNode(&parent);
    58 		if ( NS_SUCCEEDED(status) )
    59 			{
    60 				parent->GetNodeName(*aResult);
    61 				NS_RELEASE(parent);
    62 			}
    64 //		return status;
    65 	}
    68 void // nsresult
    69 Test03_nsCOMPtr( nsIDOMNode* aDOMNode, nsString* aResult )
    70 		// m144, w54/59
    71 	{
    72 //		if ( !aDOMNode || !aResult )
    73 //			return NS_ERROR_NULL_POINTER;
    75 		nsCOMPtr<nsIDOMNode> parent;
    76 		nsresult status = aDOMNode->GetParentNode( getter_AddRefs(parent) );
    77 		if ( parent )
    78 			parent->GetNodeName(*aResult);
    80 //		return status;
    81 	}
    83 void // nsresult
    84 Test03_nsCOMPtr_optimized( nsIDOMNode* aDOMNode, nsString* aResult )
    85 		// m112, w50/45
    86 	{
    87 //		if ( !aDOMNode || !aResult )
    88 //			return NS_ERROR_NULL_POINTER;
    90 		nsIDOMNode* temp;
    91 		nsresult status = aDOMNode->GetParentNode(&temp);
    92 		nsCOMPtr<nsIDOMNode> parent( dont_AddRef(temp) );
    93 		if ( parent )
    94 			parent->GetNodeName(*aResult);
    96 //		return status;
    97 	}

mercurial