diff --git a/xpcom/glue/nsTArray.h b/xpcom/glue/nsTArray.h index b7e4c964847e..7fb2ca11e1bb 100644 --- a/xpcom/glue/nsTArray.h +++ b/xpcom/glue/nsTArray.h @@ -381,24 +381,6 @@ public: } }; -// This class exists because VC6 cannot handle static template functions. -// Otherwise, the Compare method would be defined directly on nsTArray. -template -class nsQuickSortComparator -{ -public: - typedef E elem_type; - // This function is meant to be used with the NS_QuickSort function. It - // maps the callback API expected by NS_QuickSort to the Comparator API - // used by nsTArray. See nsTArray::Sort. - static int Compare(const void* e1, const void* e2, void *data) { - const Comparator* c = reinterpret_cast(data); - const elem_type* a = static_cast(e1); - const elem_type* b = static_cast(e2); - return c->LessThan(*a, *b) ? -1 : (c->Equals(*a, *b) ? 0 : 1); - } -}; - // The default comparator used by nsTArray template class nsDefaultComparator @@ -1131,6 +1113,17 @@ public: // // Sorting // + + // This function is meant to be used with the NS_QuickSort function. It + // maps the callback API expected by NS_QuickSort to the Comparator API + // used by nsTArray. See nsTArray::Sort. + template + static int Compare(const void* e1, const void* e2, void *data) { + const Comparator* c = reinterpret_cast(data); + const elem_type* a = static_cast(e1); + const elem_type* b = static_cast(e2); + return c->LessThan(*a, *b) ? -1 : (c->Equals(*a, *b) ? 0 : 1); + } // This method sorts the elements of the array. It uses the LessThan // method defined on the given Comparator object to collate elements. @@ -1138,8 +1131,7 @@ public: template void Sort(const Comparator& comp) { NS_QuickSort(Elements(), Length(), sizeof(elem_type), - nsQuickSortComparator::Compare, - const_cast(&comp)); + Compare, const_cast(&comp)); } // A variation on the Sort method defined above that assumes that