Hi, Looking at commits f10eab73d and c50d192c, I wondered why we don't have a reusable in-place unique function. It may be trivial, but we seem to have a lot of copies and variations in the tree.
Here's a sketch patch that creates a function array_unique which takes the same arguments as qsort or qsort_arg and returns the new length. The patch replaces all the specialised unique functions and open coded versions that I could find with simple greps, but there are probably more. My compiler seems to inline the comparator function and memcpy well, so I can't measure any speed difference between array_unique(array, size, sizeof(int), compare_int) and a hand-crafted loop using == for comparison and = for assignment, for a billion items. If no one objects I'll post a version of this to a commitfest, along with some other trivial code duplication refactoring work I posted a while back that consolidates popcount and ffs/fls implementations. I don't like code duplication :-) -- Thomas Munro http://www.enterprisedb.com
Description: Binary data
-- Sent via pgsql-hackers mailing list (email@example.com) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers