[PATCH 0/2] [GSOC][RFC] ref-filter: introduce enum atom_type
- From
ZheNing Hu via GitGitGadget <gitgitgadget@gmail.com>
- Date
- May 8, 2021, 15:22 UTC
- Message-ID
- <pull.951.git.1620487353.gitgitgadget@gmail.com>
Firstly, let the union used_atom.u add a member "objectsize",which learn to record the attributes of "objectsize", this will bring an extension line for atom "%(objectsize)". Next patch will base on this feature to better support its functions.
Secondly, In https://lore.kernel.org/git/CAOLTT8RhVZQJX8z1gY5UM1jv0imZ4K9UnD14MgJFfvqBBiAZQg@mail.gmail.com/ I and Junio discussed the use of enum atom_type in used_atom to represent the specific type of union used_atom.u, which can correctly distinguish atom types and reduce the overhead of string matching.
But after my attempts, I found that our used_atom is better using enum to remember the type of valid_atom item instead of remember type of used_atom.u, which can be used throughout the ref-filter, easily distinguish different types of atoms through a used_atom[i].atom_type, and reduce the overhead of string matching.
What's left: some function like grab_oid() or grab_person(), they can also take advantage of this feature, but require some additional modifications.
What's for future: Let used_atom entry can index directly by enum atom_type, In order to reduce the very many loops in ref-filter.
E.g.
static struct used_atom_cache { enum atom_type atom_type; struct used_atom *used_atom; } used_atom_cache[] = { {ATOM_REFNAME, NULL}, {ATOM_OBJECTTYPE, NULL}, ... };
If want check whether used_atom entries have a atom "%(refname)", we can just check if used_atom_cache[ATOM_REFNAME].used_atom is equal to NULL, the time complexity is O(1) and the complexity of the original method is O(n). This will once again get a performance boost for ref-filter.
ZheNing Hu (2): [GSOC] ref-filter: add objectsize to used_atom [GSOC][RFC] ref-filter: introduce enum atom_type
ref-filter.c | 209 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 135 insertions(+), 74 deletions(-)
base-commit: 7e391989789db82983665667013a46eabc6fc570 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-951%2Fadlternative%2Fref-filter-atom-type-v1 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-951/adlternative/ref-filter-atom-type-v1 Pull-Request: https://github.com/gitgitgadget/git/pull/951
-- gitgitgadget