Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2020-06-23 18:24:58 +0300
committerJunio C Hamano <gitster@pobox.com>2020-06-24 05:56:26 +0300
commit55b01456a95ac8d92b04d58b874459f3bf70ad2c (patch)
treee221ec694686b857e44b038d971568f4af25dd62 /builtin
parenta0f65641dfb67ffa94f1e33ded2cbab8d77d53a5 (diff)
fast-export: use a flex array to store anonymized entries
Now that we're using a separate keydata struct for hash lookups, we have more flexibility in how we allocate anonymized_entry structs. Let's push the "orig" key into a flex member within the struct. That should save us a few bytes of memory per entry (a pointer plus any malloc overhead), and may make lookups a little faster (since it's one less pointer to chase in the comparison function). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/fast-export.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 5df2ada47d..99d4a2b404 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -120,8 +120,8 @@ static int has_unshown_parent(struct commit *commit)
struct anonymized_entry {
struct hashmap_entry hash;
- const char *orig;
const char *anon;
+ const char orig[FLEX_ARRAY];
};
struct anonymized_entry_key {
@@ -170,9 +170,8 @@ static const char *anonymize_str(struct hashmap *map,
ret = hashmap_get_entry(map, &key, hash, &key);
if (!ret) {
- ret = xmalloc(sizeof(*ret));
+ FLEX_ALLOC_MEM(ret, orig, orig, len);
hashmap_entry_init(&ret->hash, key.hash.hash);
- ret->orig = xmemdupz(orig, len);
ret->anon = generate(orig, len);
hashmap_put(map, &ret->hash);
}