Bug 1368326: Don't bother calling Clear() in destructor for empty nsTArrays. r=froydnj
authorDaniel Holbert <dholbert@cs.stanford.edu>
Thu, 01 Jun 2017 14:38:13 -0700
changeset 412550 627055e30ca40ca5f4f7174dbcd2fb76a4ba73a9
parent 412549 5baa39559276cd83a14d020e7c06b84574e99bce
child 412551 0d50eaa8bfa0bdfb5a7d039360ba54124551a7cf
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1368326
milestone55.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 1368326: Don't bother calling Clear() in destructor for empty nsTArrays. r=froydnj MozReview-Commit-ID: 7mi2Os52JfJ
xpcom/ds/nsTArray.h
--- a/xpcom/ds/nsTArray.h
+++ b/xpcom/ds/nsTArray.h
@@ -874,17 +874,22 @@ public:
   static const index_type NoIndex = index_type(-1);
 
   using base_type::Length;
 
   //
   // Finalization method
   //
 
-  ~nsTArray_Impl() { Clear(); }
+  ~nsTArray_Impl()
+  {
+    if (!base_type::IsEmpty()) {
+      Clear();
+    }
+  }
 
   //
   // Initialization methods
   //
 
   nsTArray_Impl() {}
 
   // Initialize this array and pre-allocate some number of elements.