Bug 1428748 - RangeBoundary is too AddRef/Release heavy, r=mystor
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Mon, 08 Jan 2018 21:27:44 +0200
changeset 452668 469468b7a0706f5c14c3eef902e09ab693832a35
parent 452667 d2a67cf4639a9bbff277421aa5823643d0d5dc05
child 452669 a0cf29a08c3d44b62d740cea24f524a9c8fd450b
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmystor
bugs1428748
milestone59.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 1428748 - RangeBoundary is too AddRef/Release heavy, r=mystor
dom/base/RangeBoundary.h
--- a/dom/base/RangeBoundary.h
+++ b/dom/base/RangeBoundary.h
@@ -282,18 +282,24 @@ public:
   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;
+    // mParent and mRef can be strong pointers, so better to try to avoid any
+    // extra AddRef/Release calls.
+    if (mParent != aOther.mParent) {
+      mParent = aOther.mParent;
+    }
+    if (mRef != aOther.mRef) {
+      mRef = aOther.mRef;
+    }
     mOffset = aOther.mOffset;
     return *this;
   }
 
   template<typename A, typename B>
   bool operator==(const RangeBoundaryBase<A, B>& aOther) const
   {
     return mParent == aOther.mParent &&