Bug 1308317 - Part 7: Remove nsSupportsArray::RemoveElementsAt. r=froydnj
☠☠ backed out by 080a3dc2c637 ☠ ☠
authorEric Rahm <erahm@mozilla.com>
Thu, 13 Oct 2016 22:04:41 -0700
changeset 317943 928ad5e9337239c5c8effc00ac42fb1140351a71
parent 317942 8c2984643f74f33137675b00b95398a9116ea175
child 317944 96d1b7238832ebf3e7e03053db19a8e557f6ca42
push id33170
push usercbook@mozilla.com
push dateFri, 14 Oct 2016 10:37:07 +0000
treeherderautoland@0d101ebfd95c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1308317
milestone52.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 1308317 - Part 7: Remove nsSupportsArray::RemoveElementsAt. r=froydnj MozReview-Commit-ID: H3A3gxckw5o
xpcom/ds/nsISupportsArray.idl
xpcom/ds/nsSupportsArray.cpp
xpcom/ds/nsSupportsArray.h
--- a/xpcom/ds/nsISupportsArray.idl
+++ b/xpcom/ds/nsISupportsArray.idl
@@ -49,19 +49,16 @@ interface nsISupportsArray : nsICollecti
   
   // xpcom-compatible versions
   void DeleteElementAt(in unsigned long aIndex);
   
   void Compact();
   
 
   nsISupportsArray clone();
-
-  [notxpcom] boolean RemoveElementsAt(in unsigned long aIndex,
-                                      in unsigned long aCount);
 };
 
 %{C++
 
 // Construct and return a default implementation of nsISupportsArray:
 extern MOZ_MUST_USE nsresult
 NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult);
 
--- a/xpcom/ds/nsSupportsArray.cpp
+++ b/xpcom/ds/nsSupportsArray.cpp
@@ -278,26 +278,25 @@ nsSupportsArray::ReplaceElementAt(nsISup
     NS_IF_RELEASE(mArray[aIndex]);
     mArray[aIndex] = aElement;
     return true;
   }
   return false;
 }
 
 NS_IMETHODIMP_(bool)
-nsSupportsArray::RemoveElementsAt(uint32_t aIndex, uint32_t aCount)
+nsSupportsArray::RemoveElementAt(uint32_t aIndex)
 {
-  if (aIndex + aCount <= mCount) {
-    for (uint32_t i = 0; i < aCount; i++) {
-      NS_IF_RELEASE(mArray[aIndex + i]);
-    }
-    mCount -= aCount;
+  if (aIndex + 1 <= mCount) {
+    NS_IF_RELEASE(mArray[aIndex]);
+
+    mCount -= 1;
     int32_t slide = (mCount - aIndex);
     if (0 < slide) {
-      ::memmove(mArray + aIndex, mArray + aIndex + aCount,
+      ::memmove(mArray + aIndex, mArray + aIndex + 1,
                 slide * sizeof(nsISupports*));
     }
     return true;
   }
   return false;
 }
 
 NS_IMETHODIMP
--- a/xpcom/ds/nsSupportsArray.h
+++ b/xpcom/ds/nsSupportsArray.h
@@ -77,33 +77,27 @@ public:
 
   MOZ_MUST_USE NS_IMETHOD_(bool)
   InsertElementAt(nsISupports* aElement, uint32_t aIndex) override;
 
   MOZ_MUST_USE NS_IMETHOD_(bool)
   ReplaceElementAt(nsISupports* aElement, uint32_t aIndex) override;
 
   MOZ_MUST_USE NS_IMETHOD_(bool)
-  RemoveElementAt(uint32_t aIndex) override
-  {
-    return RemoveElementsAt(aIndex, 1);
-  }
+  RemoveElementAt(uint32_t aIndex) override;
 
   MOZ_MUST_USE NS_IMETHOD DeleteElementAt(uint32_t aIndex) override
   {
     return (RemoveElementAt(aIndex) ? NS_OK : NS_ERROR_FAILURE);
   }
 
   NS_IMETHOD Compact(void) override;
 
   MOZ_MUST_USE NS_IMETHOD Clone(nsISupportsArray** aResult) override;
 
-  MOZ_MUST_USE NS_IMETHOD_(bool)
-  RemoveElementsAt(uint32_t aIndex, uint32_t aCount) override;
-
 protected:
   void DeleteArray(void);
 
   bool GrowArrayBy(uint32_t aGrowBy);
 
   nsISupports** mArray;
   uint32_t mArraySize;
   uint32_t mCount;