[cfe-dev] [libc++] Improve std::sort over std::array<T, N> for small values of N‏

Morwenn Ed morwenn29 at hotmail.fr
Mon Aug 3 11:48:55 PDT 2015


This is a repost of a mail I sent to the libstdc++ mailing list, but it might
actually be interesting for libc++ as well. Here it is:

> I have developed a small library to complete std::sort. Basically, the 
> idea is to use specific decicated algorithms for a small number of 
> values when that number of values is known at compile time. You can 
> find the library here: https://github.com/Morwenn/cpp-sort

> When given an std::array, the sort function of the library uses a specific 
> sorting algorithm (based on sorting networks) for the given number of 
> values if it has one and falls back to std::sort if it doesn't. I 
> believe that it could be possible to add an overload to the 
> implementation of std::sort which would take instances of 
> std::array<T, N>::iterator and use a specific sorting algorithm 
> for small values of N. It would incur no runtime overhead and would 
> allow to sort small arrays for "free" instead of using the general 
> purpose version of std::sort which sometimes feel overkill for the job.

Would you be interested in such an optimization for libc++?

 		 	   		  




More information about the cfe-dev mailing list