]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* sort.c (backtrace_qsort): Use middle element as pivot.
authorIan Lance Taylor <iant@google.com>
Fri, 7 Mar 2014 15:52:48 +0000 (15:52 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Fri, 7 Mar 2014 15:52:48 +0000 (15:52 +0000)
From-SVN: r208403

libbacktrace/ChangeLog
libbacktrace/sort.c

index abbea3ed6e8b46e0796ce481c939b254a1e2b370..8a1a8e74a323d8547f2425836aa1516dc3e6df76 100644 (file)
@@ -1,3 +1,7 @@
+2014-03-07  Ian Lance Taylor  <iant@google.com>
+
+       * sort.c (backtrace_qsort): Use middle element as pivot.
+
 2014-03-06  Ian Lance Taylor  <iant@google.com>
 
        * sort.c: New file.
index 88f9231422472eac95d41194115ede9e84ceceb4..8c4760f8aa31cc1a2bccc62ca921a7b94c092dc1 100644 (file)
@@ -69,6 +69,12 @@ backtrace_qsort (void *basearg, size_t count, size_t size,
   if (count < 2)
     return;
 
+  /* The symbol table and DWARF tables, which is all we use this
+     routine for, tend to be roughly sorted.  Pick the middle element
+     in the array as our pivot point, so that we are more likely to
+     cut the array in half for each recursion step.  */
+  swap (base, base + (count / 2) * size, size);
+
   mid = 0;
   for (i = 1; i < count; i++)
     {