]> Savannah Git Hosting - gnulib.git/commit
savedir: scale better when sorting by name
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 12 Dec 2023 01:47:38 +0000 (17:47 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 12 Dec 2023 02:29:36 +0000 (18:29 -0800)
commit6918b22315abaa8c64f590470b5f0f9749496928
tree42395d81cc4978785fe9e63d266525c98e880429
parent3bb26f17cbb32c4129c4a26cd6122bd2227ddf05
savedir: scale better when sorting by name

* lib/savedir.c: Include attribute.h.
(direntry_t): The ‘name’ member is now idx_t, not char *,
so that it survives name_space relocation.
(direntry_cmp_name, direntry_cmp_inode, comparison_function):
Adjust to qsort_r API, and to direntry_t layout change.
(streamsavedir): Redo to avoid need for xstrdup on each directory
entry.  Instead, copy the string data into name_space; this
typically scales better the memory allocator is called O(log N)
rather than O(N) times.  Use qsort_r so that name_space can be
passed to the comparison functions.  Simplify calls to ‘free’ so
that lack of leakage is more obvious.
* modules/savedir (Depends-on): Add attribute, qsort_r.
ChangeLog
lib/savedir.c
modules/savedir