pgsql: Replace insertion sort in contrib/intarray with qsort(). - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Replace insertion sort in contrib/intarray with qsort().
Date
Msg-id E1YXLbl-0008I5-2l@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Replace insertion sort in contrib/intarray with qsort().

It's all very well to claim that a simplistic sort is fast in easy
cases, but O(N^2) in the worst case is not good ... especially if the
worst case is as easy to hit as "descending order input".  Replace that
bit with our standard qsort.

Per bug #12866 from Maksym Boguk.  Back-patch to all active branches.

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/9288645b596efde3a58e267896b38f8f089a2920

Modified Files
--------------
contrib/intarray/_int_tool.c |   52 +++++++++++++++++++-----------------------
1 file changed, 23 insertions(+), 29 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Replace insertion sort in contrib/intarray with qsort().
Next
From: Alvaro Herrera
Date:
Subject: pgsql: Support opfamily members in get_object_address