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
This commit is contained in:
Eric Rahm 2016-10-18 11:36:38 -07:00
Родитель 7292673607
Коммит 7fde5ad2f6
4 изменённых файлов: 1 добавлений и 28 удалений

Просмотреть файл

@ -34,11 +34,9 @@ class nsISupportsArray;
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);

Просмотреть файл

@ -221,21 +221,6 @@ nsSupportsArray::IndexOf(const nsISupports* aPossibleElement)
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)
{

Просмотреть файл

@ -61,7 +61,6 @@ public:
// 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
{
@ -69,12 +68,6 @@ public:
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;

Просмотреть файл

@ -118,13 +118,10 @@ TEST(Array, main)
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);