Bug 1308317 - Part 8: Remove nsSupportsArray::LastIndexOf. r=froydnj
authorEric Rahm <erahm@mozilla.com>
Tue, 18 Oct 2016 11:36:38 -0700
changeset 318533 dea75d69f2f6627d6546e4e67a69f350963d239c
parent 318532 b4f59500a7c9fdaca4057b29a5e59533b3d4a5e5
child 318534 f84c2e169172ff89fe43850feaa5def5c9227072
push id20725
push userphilringnalda@gmail.com
push dateThu, 20 Oct 2016 01:36:01 +0000
treeherderfx-team@998ad5a74da8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1308317
milestone52.0a1
Bug 1308317 - Part 8: Remove nsSupportsArray::LastIndexOf. r=froydnj This removes the scriptable method |GetLastIndexOf| which is unused in our codebase and turns up no references in the plugins repo. This allows to remove the non-scriptable |LastIndexOf|. MozReview-Commit-ID: 54Ux7yZMh4F
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
@@ -29,21 +29,19 @@ class nsISupportsArray;
 #define NS_SUPPORTSARRAY_CONTRACTID "@mozilla.org/supports-array;1"
  
 %}
 
 [scriptable, uuid(241addc8-3608-4e73-8083-2fd6fa09eba2)]
 interface nsISupportsArray : nsICollection {
 
   [notxpcom] long IndexOf([const] in nsISupports aPossibleElement);
-  [notxpcom] long LastIndexOf([const] in nsISupports aPossibleElement);
   
   // xpcom-compatible versions
   long GetIndexOf(in nsISupports aPossibleElement);
-  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);
   
--- a/xpcom/ds/nsSupportsArray.cpp
+++ b/xpcom/ds/nsSupportsArray.cpp
@@ -216,31 +216,16 @@ nsSupportsArray::IndexOf(const nsISuppor
     if (aPossibleElement == *ep) {
       return (ep - start);
     }
     ep++;
   }
   return -1;
 }
 
-NS_IMETHODIMP_(int32_t)
-nsSupportsArray::LastIndexOf(const nsISupports* aPossibleElement)
-{
-  if (0 < mCount) {
-    const nsISupports** start = (const nsISupports**)mArray;  // work around goofy compiler behavior
-    const nsISupports** ep = (start + mCount);
-    while (start <= --ep) {
-      if (aPossibleElement == *ep) {
-        return (ep - start);
-      }
-    }
-  }
-  return -1;
-}
-
 NS_IMETHODIMP_(bool)
 nsSupportsArray::InsertElementAt(nsISupports* aElement, uint32_t aIndex)
 {
   if (aIndex <= mCount) {
     CheckedUint32 newCount(mCount);
     newCount += 1;
     if (!newCount.isValid()) {
       return false;
--- a/xpcom/ds/nsSupportsArray.h
+++ b/xpcom/ds/nsSupportsArray.h
@@ -56,30 +56,23 @@ public:
   }
   // XXX this is badly named - should be RemoveFirstElement
   MOZ_MUST_USE NS_IMETHOD RemoveElement(nsISupports* aElement) override;
   NS_IMETHOD Enumerate(nsIEnumerator** aResult) override;
   NS_IMETHOD Clear(void) override;
 
   // nsISupportsArray methods:
   NS_IMETHOD_(int32_t) IndexOf(const nsISupports* aPossibleElement) override;
-  NS_IMETHOD_(int32_t) LastIndexOf(const nsISupports* aPossibleElement) override;
 
   NS_IMETHOD GetIndexOf(nsISupports* aPossibleElement, int32_t* aResult) override
   {
     *aResult = IndexOf(aPossibleElement);
     return NS_OK;
   }
 
-  NS_IMETHOD GetLastIndexOf(nsISupports* aPossibleElement, int32_t* aResult) override
-  {
-    *aResult = LastIndexOf(aPossibleElement);
-    return NS_OK;
-  }
-
   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;
--- a/xpcom/glue/tests/gtest/TestArray.cpp
+++ b/xpcom/glue/tests/gtest/TestArray.cpp
@@ -113,23 +113,20 @@ TEST(Array, main)
     array->InsertElementAt(foo, 0);
     int32_t   insertResult2[12] = {3, 0, 1, 2, 3, 4, 3, 5, 6, 7, 8, 9};
     CheckArray(array, 12, insertResult2, 10);
     array->AppendElement(foo);
     int32_t   appendResult[13] = {3, 0, 1, 2, 3, 4, 3, 5, 6, 7, 8, 9, 3};
     CheckArray(array, 13, appendResult, 10);
 
 
-    // test IndexOf && LastIndexOf
+    // test IndexOf
     int32_t expectedIndex = 0;
     int32_t index = array->IndexOf(foo);
     EXPECT_EQ(index, expectedIndex);
-    expectedIndex = 12;
-    index = array->LastIndexOf(foo);
-    EXPECT_EQ(index, expectedIndex);
 
     // 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
     array->RemoveElementAt(0);