Bug 1398153 - Try to Release/AddRef a bit less in nsRange::DoSetRange, r=baku
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Fri, 08 Sep 2017 15:22:05 +0100
changeset 429264 d8ce26333a8b3b45a26199d79e8db6cc553c8068
parent 429263 bd81dcf6af6067eff31ce2517b4cad9913188253
child 429265 2b23fd4108d10f8e829902819962ab017c877acb
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1398153
milestone57.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 1398153 - Try to Release/AddRef a bit less in nsRange::DoSetRange, r=baku
dom/base/nsRange.h
--- a/dom/base/nsRange.h
+++ b/dom/base/nsRange.h
@@ -594,18 +594,24 @@ protected:
     AsRaw() const
     {
       return RangeBoundaryBase<nsINode*, nsIContent*>(*this);
     }
 
     template<typename A, typename B>
     RangeBoundaryBase& operator=(const RangeBoundaryBase<A,B>& aOther)
     {
-      mParent = aOther.mParent;
-      mRef = aOther.mRef;
+      // Since the member variables may be nsCOMPtrs, better to try to avoid
+      // extra Release/AddRef calls.
+      if (mParent != aOther.mParent) {
+        mParent = aOther.mParent;
+      }
+      if (mRef != aOther.mRef) {
+        mRef = aOther.mRef;
+      }
       mOffset = aOther.mOffset;
       return *this;
     }
 
   private:
     ParentType mParent;
     RefType mRef;