|
1 // Test06.cpp |
|
2 |
|
3 #include "nsPIDOMWindow.h" |
|
4 #include "nsIDocShell.h" |
|
5 #include "nsIBaseWindow.h" |
|
6 #include "nsCOMPtr.h" |
|
7 |
|
8 NS_DEF_PTR(nsPIDOMWindow); |
|
9 NS_DEF_PTR(nsIBaseWindow); |
|
10 |
|
11 /* |
|
12 Windows: |
|
13 nsCOMPtr_optimized 176 |
|
14 nsCOMPtr_as_found 181 |
|
15 nsCOMPtr_optimized* 182 |
|
16 nsCOMPtr02* 184 |
|
17 nsCOMPtr02 187 |
|
18 nsCOMPtr02* 188 |
|
19 nsCOMPtr03 189 |
|
20 raw_optimized, nsCOMPtr00 191 |
|
21 nsCOMPtr00* 199 |
|
22 nsCOMPtr_as_found* 201 |
|
23 raw 214 |
|
24 |
|
25 Macintosh: |
|
26 nsCOMPtr_optimized 300 (1.0000) |
|
27 nsCOMPtr02 320 (1.0667) i.e., 6.67% bigger than nsCOMPtr_optimized |
|
28 nsCOMPtr00 328 (1.0933) |
|
29 raw_optimized, nsCOMPtr03 332 (1.1067) |
|
30 nsCOMPtr_as_found 344 (1.1467) |
|
31 raw 388 (1.2933) |
|
32 |
|
33 */ |
|
34 |
|
35 |
|
36 void // nsresult |
|
37 Test06_raw(nsIDOMWindow* aDOMWindow, nsIBaseWindow** aBaseWindow) |
|
38 // m388, w214 |
|
39 { |
|
40 // if (!aDOMWindow) |
|
41 // return NS_ERROR_NULL_POINTER; |
|
42 nsPIDOMWindow* window = 0; |
|
43 nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsPIDOMWindow), (void**)&window); |
|
44 nsIDocShell* docShell = 0; |
|
45 if (window) |
|
46 window->GetDocShell(&docShell); |
|
47 nsIWebShell* rootWebShell = 0; |
|
48 NS_IF_RELEASE(rootWebShell); |
|
49 NS_IF_RELEASE(docShell); |
|
50 NS_IF_RELEASE(window); |
|
51 // return status; |
|
52 } |
|
53 |
|
54 void // nsresult |
|
55 Test06_raw_optimized(nsIDOMWindow* aDOMWindow, nsIBaseWindow** aBaseWindow) |
|
56 // m332, w191 |
|
57 { |
|
58 // if (!aDOMWindow) |
|
59 // return NS_ERROR_NULL_POINTER; |
|
60 (*aBaseWindow) = 0; |
|
61 nsPIDOMWindow* window; |
|
62 nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsPIDOMWindow), (void**)&window); |
|
63 if (NS_SUCCEEDED(status)) { |
|
64 nsIDocShell* docShell = 0; |
|
65 window->GetDocShell(&docShell); |
|
66 if (docShell) { |
|
67 NS_RELEASE(docShell); |
|
68 } |
|
69 NS_RELEASE(window); |
|
70 } |
|
71 // return status; |
|
72 } |
|
73 |
|
74 void |
|
75 Test06_nsCOMPtr_as_found(nsIDOMWindow* aDOMWindow, nsCOMPtr<nsIBaseWindow>* aBaseWindow) |
|
76 // m344, w181/201 |
|
77 { |
|
78 // if (!aDOMWindow) |
|
79 // return; |
|
80 nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aDOMWindow); |
|
81 nsCOMPtr<nsIDocShell> docShell; |
|
82 if (window) |
|
83 window->GetDocShell(getter_AddRefs(docShell)); |
|
84 } |
|
85 |
|
86 void // nsresult |
|
87 Test06_nsCOMPtr00(nsIDOMWindow* aDOMWindow, nsIBaseWindow** aBaseWindow) |
|
88 // m328, w191/199 |
|
89 { |
|
90 // if (!aDOMWindow) |
|
91 // return NS_ERROR_NULL_POINTER; |
|
92 nsresult status; |
|
93 nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aDOMWindow, &status); |
|
94 nsIDocShell* temp0 = 0; |
|
95 if (window) |
|
96 window->GetDocShell(&temp0); |
|
97 nsCOMPtr<nsIDocShell> docShell = dont_AddRef(temp0); |
|
98 (*aBaseWindow) = 0; |
|
99 // return status; |
|
100 } |
|
101 |
|
102 void // nsresult |
|
103 Test06_nsCOMPtr_optimized(nsIDOMWindow* aDOMWindow, nsCOMPtr<nsIBaseWindow>* aBaseWindow) |
|
104 // m300, w176/182 |
|
105 { |
|
106 // if (!aDOMWindow) |
|
107 // return NS_ERROR_NULL_POINTER; |
|
108 nsresult status; |
|
109 nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aDOMWindow, &status); |
|
110 nsIDocShell* temp0 = 0; |
|
111 if (window) |
|
112 window->GetDocShell(&temp0); |
|
113 (*aBaseWindow) = do_QueryInterface(nullptr, &status); |
|
114 // return status; |
|
115 } |
|
116 |
|
117 void // nsresult |
|
118 Test06_nsCOMPtr02(nsIDOMWindow* aDOMWindow, nsIBaseWindow** aBaseWindow) |
|
119 // m320, w187/184 |
|
120 { |
|
121 // if (!aDOMWindow) |
|
122 // return NS_ERROR_NULL_POINTER; |
|
123 (*aBaseWindow) = 0; |
|
124 nsresult status; |
|
125 nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aDOMWindow, &status); |
|
126 if (window) { |
|
127 nsIDocShell* temp0; |
|
128 window->GetDocShell(&temp0); |
|
129 } |
|
130 // return status; |
|
131 } |
|
132 |
|
133 void // nsresult |
|
134 Test06_nsCOMPtr03(nsIDOMWindow* aDOMWindow, nsCOMPtr<nsIBaseWindow>* aBaseWindow) |
|
135 // m332, w189/188 |
|
136 { |
|
137 // if (!aDOMWindow) |
|
138 // return NS_ERROR_NULL_POINTER; |
|
139 (*aBaseWindow) = 0; |
|
140 nsresult status; |
|
141 nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aDOMWindow, &status); |
|
142 if (window) { |
|
143 nsIDocShell* temp0; |
|
144 window->GetDocShell(&temp0); |
|
145 nsCOMPtr<nsIDocShell> docShell = dont_AddRef(temp0); |
|
146 if (docShell) { |
|
147 } |
|
148 } |
|
149 // return status; |
|
150 } |