Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dir.c: get rid of lazy initialization
Remove the "Lazy initialization" in prep_exclude() left behind by aceb942 (prep_exclude: remove the artificial PATH_MAX limit, 2014-07-14). Let's instead have the one remaining caller that didn't go through the DIR_INIT macro I added in ce93a4c (dir.[ch]: replace dir_init() with DIR_INIT, 2021-07-01) use a new unpack_trees_init() function instead. We could continue to pre-grow the buffer here to something like PATH_MAX, but that we were using PATH_MAX at all is just a relic from this being a fixed buffer from way back in f87f949 (git-ls-files: --exclude mechanism updates., 2005-07-24). I don't think something that's about to do I/O on one file here needs to be concerned about micro-optimizing the allocation pattern. It would arguably make more sense to not do this in unpack_trees_start() in "merge-recursive.c", but to instead do it when we do the "CALLOC_ARRAY(opt->priv)" in "merge_start()", or in turn to have "init_merge_options()" do that allocation itself. But as "merge-recursive.c" is going away sooner than later let's just do the bare minimum here, hopefully we'll be able to remove this sooner than later, and perhaps our new "unpack_trees_init()" along with that removal. The "merge-ort.c" allocation pattern is (of course) closer to the end-state that would make senes for "merge-recursive.c" in this case. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Loading branch information