Bug 674284: Add nsTArray::SizeOf. r=bsmedberg
☠☠ backed out by 9517e7652dec ☠ ☠
authorKyle Huey <khuey@kylehuey.com>
Mon, 01 Aug 2011 08:11:26 -0400
changeset 73559 030c419226ed013199d59b9049c7e2e09e933f04
parent 73558 2cdff940a6c86f817688cfb2ceb0779400bd34ce
child 73560 9517e7652dece18e35e0643ff93bc49c8540d40c
push id20894
push userkhuey@mozilla.com
push dateMon, 01 Aug 2011 12:11:40 +0000
treeherdermozilla-central@030c419226ed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs674284
milestone8.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 674284: Add nsTArray::SizeOf. r=bsmedberg
xpcom/glue/nsTArray.h
--- a/xpcom/glue/nsTArray.h
+++ b/xpcom/glue/nsTArray.h
@@ -425,16 +425,22 @@ public:
   }
 
   template<typename Allocator>
   nsTArray& operator=(const nsTArray<E, Allocator>& other) {
     ReplaceElementsAt(0, Length(), other.Elements(), other.Length());
     return *this;
   }
 
+  // @return The amount of memory taken used by this nsTArray, not including
+  // sizeof(this)
+  size_t SizeOf() const {
+    return Capacity() * sizeof(elem_type) + sizeof(mHdr);
+  }
+
   //
   // Accessor methods
   //
 
   // This method provides direct access to the array elements.
   // @return A pointer to the first element of the array.  If the array is
   // empty, then this pointer must not be dereferenced.
   elem_type* Elements() {