Bug 1587176 - Rename some nsCOMArray internal stuff. r=erahm

This makes the subsequent commit easier to understand.

Differential Revision: https://phabricator.services.mozilla.com/D51222

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nicholas Nethercote 2019-11-05 00:12:06 +00:00
Родитель 84be73074c
Коммит aa1586413a
3 изменённых файлов: 17 добавлений и 19 удалений

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

@ -538,8 +538,7 @@ class nsNavHistoryContainerResultNode
nsresult ReverseUpdateStats(int32_t aAccessCountChange);
// Sorting methods.
typedef nsCOMArray<nsNavHistoryResultNode>::nsCOMArrayComparatorFunc
SortComparator;
typedef nsCOMArray<nsNavHistoryResultNode>::TComparatorFunc SortComparator;
virtual uint16_t GetSortType();
static SortComparator GetSortingComparator(uint16_t aSortType);

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

@ -96,20 +96,20 @@ bool nsCOMArray_base::EnumerateBackwards(nsBaseArrayEnumFunc aFunc,
return true;
}
int nsCOMArray_base::nsCOMArrayComparator(const void* aElement1,
int nsCOMArray_base::VoidStarComparator(const void* aElement1,
const void* aElement2, void* aData) {
nsCOMArrayComparatorContext* ctx =
static_cast<nsCOMArrayComparatorContext*>(aData);
nsISupportsComparatorContext* ctx =
static_cast<nsISupportsComparatorContext*>(aData);
return (*ctx->mComparatorFunc)(*static_cast<nsISupports* const*>(aElement1),
*static_cast<nsISupports* const*>(aElement2),
ctx->mData);
}
void nsCOMArray_base::Sort(nsBaseArrayComparatorFunc aFunc, void* aData) {
void nsCOMArray_base::Sort(nsISupportsComparatorFunc aFunc, void* aData) {
if (mArray.Length() > 1) {
nsCOMArrayComparatorContext ctx = {aFunc, aData};
nsISupportsComparatorContext ctx = {aFunc, aData};
NS_QuickSort(mArray.Elements(), mArray.Length(), sizeof(nsISupports*),
nsCOMArrayComparator, &ctx);
VoidStarComparator, &ctx);
}
}

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

@ -44,17 +44,17 @@ class nsCOMArray_base {
bool EnumerateBackwards(nsBaseArrayEnumFunc aFunc, void* aData) const;
typedef int (*nsBaseArrayComparatorFunc)(nsISupports* aElement1,
typedef int (*nsISupportsComparatorFunc)(nsISupports* aElement1,
nsISupports* aElement2, void* aData);
struct nsCOMArrayComparatorContext {
nsBaseArrayComparatorFunc mComparatorFunc;
struct nsISupportsComparatorContext {
nsISupportsComparatorFunc mComparatorFunc;
void* mData;
};
static int nsCOMArrayComparator(const void* aElement1, const void* aElement2,
static int VoidStarComparator(const void* aElement1, const void* aElement2,
void* aData);
void Sort(nsBaseArrayComparatorFunc aFunc, void* aData);
void Sort(nsISupportsComparatorFunc aFunc, void* aData);
bool InsertObjectAt(nsISupports* aObject, int32_t aIndex);
void InsertElementAt(uint32_t aIndex, nsISupports* aElement);
@ -297,11 +297,10 @@ class nsCOMArray : public nsCOMArray_base {
nsCOMArray_base::ReplaceElementAt(aIndex, aElement);
}
typedef int (*nsCOMArrayComparatorFunc)(T* aElement1, T* aElement2,
void* aData);
typedef int (*TComparatorFunc)(T* aElement1, T* aElement2, void* aData);
void Sort(nsCOMArrayComparatorFunc aFunc, void* aData) {
nsCOMArray_base::Sort(nsBaseArrayComparatorFunc(aFunc), aData);
void Sort(TComparatorFunc aFunc, void* aData) {
nsCOMArray_base::Sort(nsISupportsComparatorFunc(aFunc), aData);
}
// append an object, growing the array as necessary