Bug 1308317 - Part 5: Remove nsSupportsArray::DeleteLastElement. r=froydnj
☠☠ backed out by f3c15a19c65a ☠ ☠
authorEric Rahm <erahm@mozilla.com>
Thu, 13 Oct 2016 22:04:38 -0700
changeset 317941 476a831ca87ed47159795eaa38a96dd45fcb1faf
parent 317940 bb30697071b22bf2218f9062372f71afe80efc35
child 317942 8c2984643f74f33137675b00b95398a9116ea175
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 5: Remove nsSupportsArray::DeleteLastElement. r=froydnj |DeleteLastElement| is scriptable, but a search of our add-on repo turned up no hits and there were no references in gecko code. This also allows us to remove the non-scriptable |RemoveLastElement| which was only called by |DeleteLastElement|. MozReview-Commit-ID: 20FXBrosacA
xpcom/ds/nsISupportsArray.idl
xpcom/ds/nsSupportsArray.cpp
xpcom/ds/nsSupportsArray.h
xpcom/glue/tests/gtest/TestArray.cpp
--- a/xpcom/ds/nsISupportsArray.idl
+++ b/xpcom/ds/nsISupportsArray.idl
@@ -45,20 +45,18 @@ interface nsISupportsArray : nsICollecti
   long GetLastIndexOf(in nsISupports aPossibleElement);  
   
   [notxpcom] boolean InsertElementAt(in nsISupports aElement,
                                      in unsigned long aIndex);
   [notxpcom] boolean ReplaceElementAt(in nsISupports aElement,
                                       in unsigned long aIndex);
 
   [notxpcom] boolean RemoveElementAt(in unsigned long aIndex);
-  [notxpcom] boolean RemoveLastElement([const] in nsISupports aElement);
   
   // xpcom-compatible versions
-  void DeleteLastElement(in nsISupports aElement);
   void DeleteElementAt(in unsigned long aIndex);
   
   void Compact();
   
 
   nsISupportsArray clone();
 
   [notxpcom] boolean RemoveElementsAt(in unsigned long aIndex,
--- a/xpcom/ds/nsSupportsArray.cpp
+++ b/xpcom/ds/nsSupportsArray.cpp
@@ -315,28 +315,16 @@ nsSupportsArray::RemoveElement(nsISuppor
   int32_t theIndex = IndexOfStartingAt(aElement, 0);
   if (theIndex >= 0) {
     return RemoveElementAt(theIndex) ? NS_OK : NS_ERROR_FAILURE;
   }
 
   return NS_ERROR_FAILURE;
 }
 
-NS_IMETHODIMP_(bool)
-nsSupportsArray::RemoveLastElement(const nsISupports* aElement)
-{
-  int32_t theIndex = LastIndexOf(aElement);
-  if (theIndex >= 0) {
-    return RemoveElementAt(theIndex);
-  }
-
-  return false;
-}
-
-
 NS_IMETHODIMP
 nsSupportsArray::Clear(void)
 {
   if (0 < mCount) {
     do {
       --mCount;
       NS_IF_RELEASE(mArray[mCount]);
     } while (0 != mCount);
--- a/xpcom/ds/nsSupportsArray.h
+++ b/xpcom/ds/nsSupportsArray.h
@@ -90,23 +90,16 @@ public:
   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);
   }
-  MOZ_MUST_USE NS_IMETHOD_(bool)
-  RemoveLastElement(const nsISupports* aElement) override;
-
-  MOZ_MUST_USE NS_IMETHOD DeleteLastElement(nsISupports* aElement) override
-  {
-    return (RemoveLastElement(aElement) ? NS_OK : NS_ERROR_FAILURE);
-  }
 
   MOZ_MUST_USE NS_IMETHOD DeleteElementAt(uint32_t aIndex) override
   {
     return (RemoveElementAt(aIndex) ? NS_OK : NS_ERROR_FAILURE);
   }
 
   NS_IMETHOD Compact(void) override;
 
--- a/xpcom/glue/tests/gtest/TestArray.cpp
+++ b/xpcom/glue/tests/gtest/TestArray.cpp
@@ -133,29 +133,26 @@ TEST(Array, main)
     count--;
     EXPECT_EQ(index, expectedIndex[count]);
 
     // test ReplaceElementAt
     array->ReplaceElementAt(foo, 8);
     int32_t   replaceResult[13] = {3, 0, 1, 2, 3, 4, 3, 5, 3, 7, 8, 9, 3};
     CheckArray(array, 13, replaceResult, 9);
 
-    // test RemoveElementAt, RemoveElement RemoveLastElement
+    // test RemoveElementAt, RemoveElement
     array->RemoveElementAt(0);
     int32_t   removeResult[12] = {0, 1, 2, 3, 4, 3, 5, 3, 7, 8, 9, 3};
     CheckArray(array, 12, removeResult, 9);
     array->RemoveElementAt(7);
     int32_t   removeResult2[11] = {0, 1, 2, 3, 4, 3, 5, 7, 8, 9, 3};
     CheckArray(array, 11, removeResult2, 9);
     array->RemoveElement(foo);
     int32_t   removeResult3[10] = {0, 1, 2, 4, 3, 5, 7, 8, 9, 3};
     CheckArray(array, 10, removeResult3, 9);
-    array->RemoveLastElement(foo);
-    int32_t   removeResult4[9] = {0, 1, 2, 4, 3, 5, 7, 8, 9};
-    CheckArray(array, 9, removeResult4, 9);
 
     foo = nullptr;
 
     // test clear
     array->Clear();
     FillArray(array, 4);
     CheckArray(array, 4, fillResult, 4);