зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1849965 - Use nsTArray::Sort inside url classifier EntrySort. r=emilio
Depends on D185065 Differential Revision: https://phabricator.services.mozilla.com/D186772
This commit is contained in:
Родитель
c54ac1d672
Коммит
6966706b9c
|
@ -266,28 +266,11 @@ typedef FallibleTArray<SubComplete> SubCompleteArray;
|
|||
typedef FallibleTArray<Prefix> MissPrefixArray;
|
||||
|
||||
/**
|
||||
* Compares chunks by their add chunk, then their prefix.
|
||||
*/
|
||||
template <class T>
|
||||
class EntryCompare {
|
||||
public:
|
||||
typedef T elem_type;
|
||||
static int Compare(const void* e1, const void* e2) {
|
||||
const elem_type* a = static_cast<const elem_type*>(e1);
|
||||
const elem_type* b = static_cast<const elem_type*>(e2);
|
||||
return a->Compare(*b);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sort an array of store entries. nsTArray::Sort uses Equal/LessThan
|
||||
* to sort, this does a single Compare so it's a bit quicker over the
|
||||
* large sorts we do.
|
||||
* Sort an array of store entries.
|
||||
*/
|
||||
template <class T, class Alloc>
|
||||
void EntrySort(nsTArray_Impl<T, Alloc>& aArray) {
|
||||
qsort(aArray.Elements(), aArray.Length(), sizeof(T),
|
||||
EntryCompare<T>::Compare);
|
||||
aArray.Sort([](const T& aA, const T& aB) { return aA.Compare(aB); });
|
||||
}
|
||||
|
||||
template <class T, class Alloc>
|
||||
|
|
Загрузка…
Ссылка в новой задаче