Last Comment Bug 617947 - Merge 'class nsQuickSortComparator' into 'nsTArray'
: Merge 'class nsQuickSortComparator' into 'nsTArray'
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: XPCOM (show other bugs)
: Trunk
: x86 Windows Server 2003
: -- trivial (vote)
: mozilla14
Assigned To: Matias Juntunen (:dwarfcrank)
:
Mentors:
http://mxr.mozilla.org/mozilla-centra...
Depends on: 316782
Blocks: 508760
  Show dependency treegraph
 
Reported: 2010-12-09 08:04 PST by Serge Gautherie (:sgautherie)
Modified: 2012-03-22 17:31 PDT (History)
7 users (show)
bugzillamozillaorg_serge_20140323: in‑testsuite-
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Patch to merge nsQuickSortComparator into nsTArray. (2.71 KB, patch)
2012-03-15 11:15 PDT, Matias Juntunen (:dwarfcrank)
benjamin: review+
Details | Diff | Splinter Review

Description Serge Gautherie (:sgautherie) 2010-12-09 08:04:51 PST
{
279 // This class exists because VC6 cannot handle static template functions.
280 // Otherwise, the Compare method would be defined directly on nsTArray.
281 template <class E, class Comparator>
282 class nsQuickSortComparator
283 {
284 public:
285   typedef E elem_type;
286   // This function is meant to be used with the NS_QuickSort function.  It
287   // maps the callback API expected by NS_QuickSort to the Comparator API
288   // used by nsTArray.  See nsTArray::Sort.
289   static int Compare(const void* e1, const void* e2, void *data) {
290     const Comparator* c = reinterpret_cast<const Comparator*>(data);
291     const elem_type* a = static_cast<const elem_type*>(e1);
292     const elem_type* b = static_cast<const elem_type*>(e2);
293     return c->LessThan(*a, *b) ? -1 : (c->Equals(*a, *b) ? 0 : 1);
294   }
295 };
}
Comment 1 Matias Juntunen (:dwarfcrank) 2012-03-15 11:15:10 PDT
Created attachment 606299 [details] [diff] [review]
Patch to merge nsQuickSortComparator into nsTArray.
Comment 2 :Ms2ger (⌚ UTC+1/+2) 2012-03-15 11:37:23 PDT
https://tbpl.mozilla.org/?tree=Try&rev=c7e312012f53
Comment 3 Ryan VanderMeulen [:RyanVM] 2012-03-21 16:57:12 PDT
https://hg.mozilla.org/integration/mozilla-inbound/rev/3e87be93a27d

To make life easier for those checking patches in for you, please follow the directions below for future patches. Thanks!
https://developer.mozilla.org/en/Mercurial_FAQ#How_can_I_generate_a_patch_for_somebody_else_to_check-in_for_me.3F
Comment 4 Marco Bonardo [::mak] 2012-03-22 06:42:55 PDT
https://hg.mozilla.org/mozilla-central/rev/3e87be93a27d
Comment 5 Serge Gautherie (:sgautherie) 2012-03-22 17:30:25 PDT
Comment on attachment 606299 [details] [diff] [review]
Patch to merge nsQuickSortComparator into nsTArray.

Review of attachment 606299 [details] [diff] [review]:
-----------------------------------------------------------------

::: xpcom/glue/nsTArray.h
@@ +1113,5 @@
>    //
>    // Sorting
>    //
> + 
> +  // This function is meant to be used with the NS_QuickSort function.  It

Nit: this is now a method, not a function anymore.

Note You need to log in before you can comment on or make changes to this bug.