Petter Reinholdtsen wrote:
> I just discovered a call to mergesort() in libruntime/zextract.c.
> Chris, why do the code choose mergesort() before qsort(). I beleave
> qsort is ANSI C, while mergesort() is non-standard.
yeah, but all (well, most) platforms have qsort, but some don't have
mergesort. FreeBSD does, for instance, and linux doesn't.
> Is mergesort() faster? It is missing on Linux, so I can not test...
mergesort (if implemented) is a merge sort - typically showing better
behavior if the data is already close to sorted (which the zipfile
directory listings usually are.)
on some platforms (most modern ones), qsort is already a merge sort
based algorithm. i just wanted to make sure that if the platform
implemented qsort using a quick sort algorithm, but had an similarly
named merge sort algorithm, we'd use the latter..
*shrug*
xtoph