michael@0: // Test06.cpp michael@0: michael@0: #include "nsPIDOMWindow.h" michael@0: #include "nsIDocShell.h" michael@0: #include "nsIBaseWindow.h" michael@0: #include "nsCOMPtr.h" michael@0: michael@0: NS_DEF_PTR(nsPIDOMWindow); michael@0: NS_DEF_PTR(nsIBaseWindow); michael@0: michael@0: /* michael@0: Windows: michael@0: nsCOMPtr_optimized 176 michael@0: nsCOMPtr_as_found 181 michael@0: nsCOMPtr_optimized* 182 michael@0: nsCOMPtr02* 184 michael@0: nsCOMPtr02 187 michael@0: nsCOMPtr02* 188 michael@0: nsCOMPtr03 189 michael@0: raw_optimized, nsCOMPtr00 191 michael@0: nsCOMPtr00* 199 michael@0: nsCOMPtr_as_found* 201 michael@0: raw 214 michael@0: michael@0: Macintosh: michael@0: nsCOMPtr_optimized 300 (1.0000) michael@0: nsCOMPtr02 320 (1.0667) i.e., 6.67% bigger than nsCOMPtr_optimized michael@0: nsCOMPtr00 328 (1.0933) michael@0: raw_optimized, nsCOMPtr03 332 (1.1067) michael@0: nsCOMPtr_as_found 344 (1.1467) michael@0: raw 388 (1.2933) michael@0: michael@0: */ michael@0: michael@0: michael@0: void // nsresult michael@0: Test06_raw(nsIDOMWindow* aDOMWindow, nsIBaseWindow** aBaseWindow) michael@0: // m388, w214 michael@0: { michael@0: // if (!aDOMWindow) michael@0: // return NS_ERROR_NULL_POINTER; michael@0: nsPIDOMWindow* window = 0; michael@0: nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsPIDOMWindow), (void**)&window); michael@0: nsIDocShell* docShell = 0; michael@0: if (window) michael@0: window->GetDocShell(&docShell); michael@0: nsIWebShell* rootWebShell = 0; michael@0: NS_IF_RELEASE(rootWebShell); michael@0: NS_IF_RELEASE(docShell); michael@0: NS_IF_RELEASE(window); michael@0: // return status; michael@0: } michael@0: michael@0: void // nsresult michael@0: Test06_raw_optimized(nsIDOMWindow* aDOMWindow, nsIBaseWindow** aBaseWindow) michael@0: // m332, w191 michael@0: { michael@0: // if (!aDOMWindow) michael@0: // return NS_ERROR_NULL_POINTER; michael@0: (*aBaseWindow) = 0; michael@0: nsPIDOMWindow* window; michael@0: nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsPIDOMWindow), (void**)&window); michael@0: if (NS_SUCCEEDED(status)) { michael@0: nsIDocShell* docShell = 0; michael@0: window->GetDocShell(&docShell); michael@0: if (docShell) { michael@0: NS_RELEASE(docShell); michael@0: } michael@0: NS_RELEASE(window); michael@0: } michael@0: // return status; michael@0: } michael@0: michael@0: void michael@0: Test06_nsCOMPtr_as_found(nsIDOMWindow* aDOMWindow, nsCOMPtr* aBaseWindow) michael@0: // m344, w181/201 michael@0: { michael@0: // if (!aDOMWindow) michael@0: // return; michael@0: nsCOMPtr window = do_QueryInterface(aDOMWindow); michael@0: nsCOMPtr docShell; michael@0: if (window) michael@0: window->GetDocShell(getter_AddRefs(docShell)); michael@0: } michael@0: michael@0: void // nsresult michael@0: Test06_nsCOMPtr00(nsIDOMWindow* aDOMWindow, nsIBaseWindow** aBaseWindow) michael@0: // m328, w191/199 michael@0: { michael@0: // if (!aDOMWindow) michael@0: // return NS_ERROR_NULL_POINTER; michael@0: nsresult status; michael@0: nsCOMPtr window = do_QueryInterface(aDOMWindow, &status); michael@0: nsIDocShell* temp0 = 0; michael@0: if (window) michael@0: window->GetDocShell(&temp0); michael@0: nsCOMPtr docShell = dont_AddRef(temp0); michael@0: (*aBaseWindow) = 0; michael@0: // return status; michael@0: } michael@0: michael@0: void // nsresult michael@0: Test06_nsCOMPtr_optimized(nsIDOMWindow* aDOMWindow, nsCOMPtr* aBaseWindow) michael@0: // m300, w176/182 michael@0: { michael@0: // if (!aDOMWindow) michael@0: // return NS_ERROR_NULL_POINTER; michael@0: nsresult status; michael@0: nsCOMPtr window = do_QueryInterface(aDOMWindow, &status); michael@0: nsIDocShell* temp0 = 0; michael@0: if (window) michael@0: window->GetDocShell(&temp0); michael@0: (*aBaseWindow) = do_QueryInterface(nullptr, &status); michael@0: // return status; michael@0: } michael@0: michael@0: void // nsresult michael@0: Test06_nsCOMPtr02(nsIDOMWindow* aDOMWindow, nsIBaseWindow** aBaseWindow) michael@0: // m320, w187/184 michael@0: { michael@0: // if (!aDOMWindow) michael@0: // return NS_ERROR_NULL_POINTER; michael@0: (*aBaseWindow) = 0; michael@0: nsresult status; michael@0: nsCOMPtr window = do_QueryInterface(aDOMWindow, &status); michael@0: if (window) { michael@0: nsIDocShell* temp0; michael@0: window->GetDocShell(&temp0); michael@0: } michael@0: // return status; michael@0: } michael@0: michael@0: void // nsresult michael@0: Test06_nsCOMPtr03(nsIDOMWindow* aDOMWindow, nsCOMPtr* aBaseWindow) michael@0: // m332, w189/188 michael@0: { michael@0: // if (!aDOMWindow) michael@0: // return NS_ERROR_NULL_POINTER; michael@0: (*aBaseWindow) = 0; michael@0: nsresult status; michael@0: nsCOMPtr window = do_QueryInterface(aDOMWindow, &status); michael@0: if (window) { michael@0: nsIDocShell* temp0; michael@0: window->GetDocShell(&temp0); michael@0: nsCOMPtr docShell = dont_AddRef(temp0); michael@0: if (docShell) { michael@0: } michael@0: } michael@0: // return status; michael@0: }