SizeTest06.cpp 4.0 KB

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