Bug 1368326: Don't bother calling Clear() in destructor for empty nsTArrays. r? draft
authorDaniel Holbert <dholbert@cs.stanford.edu>
Thu, 01 Jun 2017 14:38:13 -0700
changeset 587941 19cfd2ecf494530146d6faccbf4ce15ea5e594aa
parent 587844 8bd3380db77f9c6cc5e3ee8f7adc84b939d6076a
child 631406 f393eba1ff58c3b992fe5119b14d7852d7d59aa7
push id61851
push userdholbert@mozilla.com
push dateThu, 01 Jun 2017 21:38:20 +0000
bugs1368326
milestone55.0a1
Bug 1368326: Don't bother calling Clear() in destructor for empty nsTArrays. r? 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.