lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> On 19-Nov-15 05:49, Daurnimator wrote:
> >>>Why does ltablib.c now `#include <time.h>`
> >>
> >>>Because `clock()` and `time()` are used to find a pivot element for sorting.
> >Ah, somehow I missed that. This seems a poor choice....
> >Could this be made configurable via moving to llimits.h?
> 
> Those calls could be a nuisance in embedded applications.
> Perhaps replacing them with GET_PIVOT_SEED1(), GET_PIVOT_SEED2()
> macros, or just a CHOOSE_PIVOT(lo, up) macro in luaconf.h?

We have added a macro 'l_sortpivot' to simplify changing that code, but
what do you mean by "nuisance" in embedded applications? These functions
are ANSI C89, and a library can trivially implement them by returning -1.
(For both of them this is a valid implementation). If by "nuisance" you
mean expensive, we only call it for partitions larger than 100, so
it seems their cost is quite diluted in the sort work.

-- Roberto