xpcom/tests/SizeTest03.cpp

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:ffdb42eaf905
1 // Test03.cpp
2
3 #include "nsIDOMNode.h"
4 #include "nsCOMPtr.h"
5 #include "nsString.h"
6
7 NS_DEF_PTR(nsIDOMNode);
8
9 /*
10 Windows:
11 nsCOMPtr_optimized* 45
12 raw_optimized 48
13 nsCOMPtr_optimized 50
14 nsCOMPtr 54
15 nsCOMPtr* 59
16 raw 62
17
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 */
23
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
30
31 // if ( !aDOMNode || !aResult )
32 // return NS_ERROR_NULL_POINTER;
33
34 nsIDOMNode* parent = 0;
35 nsresult status = aDOMNode->GetParentNode(&parent);
36
37 if ( NS_SUCCEEDED(status) )
38 {
39 parent->GetNodeName(*aResult);
40 }
41
42 NS_IF_RELEASE(parent);
43
44 // return status;
45 }
46
47
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;
54
55 nsIDOMNode* parent;
56 nsresult status = aDOMNode->GetParentNode(&parent);
57
58 if ( NS_SUCCEEDED(status) )
59 {
60 parent->GetNodeName(*aResult);
61 NS_RELEASE(parent);
62 }
63
64 // return status;
65 }
66
67
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;
74
75 nsCOMPtr<nsIDOMNode> parent;
76 nsresult status = aDOMNode->GetParentNode( getter_AddRefs(parent) );
77 if ( parent )
78 parent->GetNodeName(*aResult);
79
80 // return status;
81 }
82
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;
89
90 nsIDOMNode* temp;
91 nsresult status = aDOMNode->GetParentNode(&temp);
92 nsCOMPtr<nsIDOMNode> parent( dont_AddRef(temp) );
93 if ( parent )
94 parent->GetNodeName(*aResult);
95
96 // return status;
97 }

mercurial