diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-07-05 13:32:56 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-07-05 13:32:56 -0700 |
commit | 5ab148dda0076a136b4afb385d96bd9cdc4d2590 (patch) | |
tree | 6e6876952e2e6a1154258c9a9e11428572d4dcf9 /cache.h | |
parent | 85ce4a6828a418a22c69a870b3e059481b4263d6 (diff) | |
parent | 70c49050d4a16a7e2990e4d3c91d9d12f62e631e (diff) | |
download | git-5ab148dda0076a136b4afb385d96bd9cdc4d2590.tar.gz |
Merge branch 'rs/sha1-name-readdir-optim'
Optimize "what are the object names already taken in an alternate
object database?" query that is used to derive the length of prefix
an object name is uniquely abbreviated to.
* rs/sha1-name-readdir-optim:
sha1_file: guard against invalid loose subdirectory numbers
sha1_file: let for_each_file_in_obj_subdir() handle subdir names
p4205: add perf test script for pretty log formats
sha1_name: cache readdir(3) results in find_short_object_filename()
Diffstat (limited to 'cache.h')
-rw-r--r-- | cache.h | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -12,6 +12,7 @@ #include "pack-revindex.h" #include "hash.h" #include "path.h" +#include "sha1-array.h" #ifndef platform_SHA_CTX /* @@ -1540,6 +1541,16 @@ extern struct alternate_object_database { struct strbuf scratch; size_t base_len; + /* + * Used to store the results of readdir(3) calls when searching + * for unique abbreviated hashes. This cache is never + * invalidated, thus it's racy and not necessarily accurate. + * That's fine for its purpose; don't use it for tasks requiring + * greater accuracy! + */ + char loose_objects_subdir_seen[256]; + struct oid_array loose_objects_cache; + char path[FLEX_ARRAY]; } *alt_odb_list; extern void prepare_alt_odb(void); @@ -1755,9 +1766,15 @@ typedef int each_loose_object_fn(const struct object_id *oid, typedef int each_loose_cruft_fn(const char *basename, const char *path, void *data); -typedef int each_loose_subdir_fn(int nr, +typedef int each_loose_subdir_fn(unsigned int nr, const char *path, void *data); +int for_each_file_in_obj_subdir(unsigned int subdir_nr, + struct strbuf *path, + each_loose_object_fn obj_cb, + each_loose_cruft_fn cruft_cb, + each_loose_subdir_fn subdir_cb, + void *data); int for_each_loose_file_in_objdir(const char *path, each_loose_object_fn obj_cb, each_loose_cruft_fn cruft_cb, |