SizeTest03.cpp 2.0 KB

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