All of lore.kernel.org
 help / color / mirror / Atom feed
From: ZheNing Hu <adlternative@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: ZheNing Hu via GitGitGadget <gitgitgadget@gmail.com>,
	Git List <git@vger.kernel.org>, Jeff King <peff@peff.net>,
	Hariom Verma <hariom18599@gmail.com>,
	Christian Couder <christian.couder@gmail.com>
Subject: Re: [PATCH v3 2/2] [GSOC] ref-filter: introduce enum atom_type
Date: Thu, 13 May 2021 17:25:57 +0800	[thread overview]
Message-ID: <CAOLTT8TuMJgETg7F7XG2FhFTC318Ag7dJ=8Zi1CG2AwQXtgHvA@mail.gmail.com> (raw)
In-Reply-To: <xmqqk0o3edxw.fsf@gitster.g>

Junio C Hamano <gitster@pobox.com> 于2021年5月13日周四 上午7:21写道:
>
> "ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > +/*
> > + * The enum atom_type is used as the coordinates of valid_atom entry.
>
> Usually we do not say "coordinates" when we talk about X of an array
> element A[X].  "... used as an index in the valid_atom[] array." perhaps.
>

Ok, use index instead of coordinates.

> > + * In the atom parsing stage, it will be passed to used_atom.atom_type
> > + * as the identifier of the atom type. We can judge the type of used_atom
>
> You seem to like the verb "judge" (it was also seen in the proposed
> log message for 1/2) and tend to overuse it when we use other verbs;
> in this particular case, probably the right verb is to "check".
>

Yes, "judge" closer to my personal language expression, I will use "check".

> > @@ -965,14 +1017,15 @@ static void grab_common_values(struct atom_value *val, int deref, struct expand_
> >
> >       for (i = 0; i < used_atom_cnt; i++) {
> >               const char *name = used_atom[i].name;
> > +             enum atom_type atom_type = used_atom[i].atom_type;
> >               struct atom_value *v = &val[i];
> >               if (!!deref != (*name == '*'))
> >                       continue;
> >               if (deref)
> >                       name++;
> > -             if (!strcmp(name, "objecttype"))
> > +             if (atom_type == ATOM_OBJECTTYPE)
> >                       v->s = xstrdup(type_name(oi->type));
> > -             else if (starts_with(name, "objectsize")) {
> > +             else if (atom_type == ATOM_OBJECTSIZE) {
> >                       if (used_atom[i].u.objectsize.option == O_SIZE_DISK) {
> >                               v->value = oi->disk_size;
> >                               v->s = xstrfmt("%"PRIuMAX, (uintmax_t)oi->disk_size);
>
> Replacing !strcmp() with comparison with ATOM_* like the above is
> the best solution for this step, but I wonder if this part (or any
> other part that this patch touches) would benefit from using a
> switch statement on atom_type.  Something to think about in the
> future, after the dust settles.
>
> Thanks.

Well, that's right, use switch can increase readability and maintainability.
This can be used as a future direction.

Thanks.
--
ZheNing Hu

  reply	other threads:[~2021-05-13  9:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-08 15:22 [PATCH 0/2] [GSOC][RFC] ref-filter: introduce enum atom_type ZheNing Hu via GitGitGadget
2021-05-08 15:22 ` [PATCH 1/2] [GSOC] ref-filter: add objectsize to used_atom ZheNing Hu via GitGitGadget
2021-05-08 15:22 ` [PATCH 2/2] [GSOC][RFC] ref-filter: introduce enum atom_type ZheNing Hu via GitGitGadget
2021-05-09  6:21   ` Christian Couder
2021-05-09  8:26     ` Junio C Hamano
2021-05-09 13:44       ` ZheNing Hu
2021-05-09 13:40     ` ZheNing Hu
2021-05-10 15:03 ` [PATCH v2 0/2] " ZheNing Hu via GitGitGadget
2021-05-10 15:03   ` [PATCH v2 1/2] [GSOC] ref-filter: add objectsize to used_atom ZheNing Hu via GitGitGadget
2021-05-10 15:03   ` [PATCH v2 2/2] [GSOC] ref-filter: introduce enum atom_type ZheNing Hu via GitGitGadget
2021-05-11  2:14     ` Junio C Hamano
2021-05-11  5:51       ` Christian Couder
2021-05-11  6:12         ` Junio C Hamano
2021-05-11 12:53           ` ZheNing Hu
2021-05-11 12:37         ` ZheNing Hu
2021-05-11 13:05         ` Junio C Hamano
2021-05-11 12:18       ` ZheNing Hu
2021-05-12 12:11   ` [PATCH v3 0/2] [GSOC][RFC] " ZheNing Hu via GitGitGadget
2021-05-12 12:11     ` [PATCH v3 1/2] [GSOC] ref-filter: add objectsize to used_atom ZheNing Hu via GitGitGadget
2021-05-12 23:11       ` Junio C Hamano
2021-05-13  9:04         ` ZheNing Hu
2021-05-12 12:11     ` [PATCH v3 2/2] [GSOC] ref-filter: introduce enum atom_type ZheNing Hu via GitGitGadget
2021-05-12 23:21       ` Junio C Hamano
2021-05-13  9:25         ` ZheNing Hu [this message]
2021-05-13 15:15     ` [PATCH v4 0/2] [GSOC][RFC] " ZheNing Hu via GitGitGadget
2021-05-13 15:15       ` [PATCH v4 1/2] [GSOC] ref-filter: add objectsize to used_atom ZheNing Hu via GitGitGadget
2021-05-13 15:15       ` [PATCH v4 2/2] [GSOC] ref-filter: introduce enum atom_type ZheNing Hu via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOLTT8TuMJgETg7F7XG2FhFTC318Ag7dJ=8Zi1CG2AwQXtgHvA@mail.gmail.com' \
    --to=adlternative@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=hariom18599@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.