diff options
| author | Junio C Hamano <gitster@pobox.com> | 2018-06-25 13:22:35 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2018-06-25 13:22:35 -0700 |
| commit | b3b2aaf0fd6c65f83d5f636bb177d96c88079b13 (patch) | |
| tree | eaa7c8b7182b645e65f26278113f5d3a9e7b13a8 /commit-slab-decl.h | |
| parent | ea27893a65cc41cad2710466aa6a58866ff22f1e (diff) | |
| parent | 9d2c97016fa09584337273ba6503e91e7c20d28e (diff) | |
| download | git-b3b2aaf0fd6c65f83d5f636bb177d96c88079b13.tar.gz | |
Merge branch 'nd/commit-util-to-slab'
The in-core "commit" object had an all-purpose "void *util" field,
which was tricky to use especially in library-ish part of the
code. All of the existing uses of the field has been migrated to a
more dedicated "commit-slab" mechanism and the field is eliminated.
* nd/commit-util-to-slab:
commit.h: delete 'util' field in struct commit
merge: use commit-slab in merge remote desc instead of commit->util
log: use commit-slab in prepare_bases() instead of commit->util
show-branch: note about its object flags usage
show-branch: use commit-slab for commit-name instead of commit->util
name-rev: use commit-slab for rev-name instead of commit->util
bisect.c: use commit-slab for commit weight instead of commit->util
revision.c: use commit-slab for show_source
sequencer.c: use commit-slab to associate todo items to commits
sequencer.c: use commit-slab to mark seen commits
shallow.c: use commit-slab for commit depth instead of commit->util
describe: use commit-slab for commit names instead of commit->util
blame: use commit-slab for blame suspects instead of commit->util
commit-slab: support shared commit-slab
commit-slab.h: code split
Diffstat (limited to 'commit-slab-decl.h')
| -rw-r--r-- | commit-slab-decl.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/commit-slab-decl.h b/commit-slab-decl.h new file mode 100644 index 0000000000..adc7b46c83 --- /dev/null +++ b/commit-slab-decl.h @@ -0,0 +1,43 @@ +#ifndef COMMIT_SLAB_HDR_H +#define COMMIT_SLAB_HDR_H + +/* allocate ~512kB at once, allowing for malloc overhead */ +#ifndef COMMIT_SLAB_SIZE +#define COMMIT_SLAB_SIZE (512*1024-32) +#endif + +#define declare_commit_slab(slabname, elemtype) \ + \ +struct slabname { \ + unsigned slab_size; \ + unsigned stride; \ + unsigned slab_count; \ + elemtype **slab; \ +} + +/* + * Statically initialize a commit slab named "var". Note that this + * evaluates "stride" multiple times! Example: + * + * struct indegree indegrees = COMMIT_SLAB_INIT(1, indegrees); + * + */ +#define COMMIT_SLAB_INIT(stride, var) { \ + COMMIT_SLAB_SIZE / sizeof(**((var).slab)) / (stride), \ + (stride), 0, NULL \ +} + +#define declare_commit_slab_prototypes(slabname, elemtype) \ + \ +void init_ ##slabname## _with_stride(struct slabname *s, unsigned stride); \ +void init_ ##slabname(struct slabname *s); \ +void clear_ ##slabname(struct slabname *s); \ +elemtype *slabname## _at_peek(struct slabname *s, const struct commit *c, int add_if_missing); \ +elemtype *slabname## _at(struct slabname *s, const struct commit *c); \ +elemtype *slabname## _peek(struct slabname *s, const struct commit *c) + +#define define_shared_commit_slab(slabname, elemtype) \ + declare_commit_slab(slabname, elemtype); \ + declare_commit_slab_prototypes(slabname, elemtype) + +#endif /* COMMIT_SLAB_HDR_H */ |
