Subject: [PATCH 0/2] [GSOC][RFC] ref-filter: introduce enum atom_type

From: "ZheNing Hu via GitGitGadget" <[email-masked]>
Date: Sat, 08 May 2021 15:22:30 +0000

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/[email-masked]/
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