git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: Jeff King <peff@peff.net>
Cc: "Sérgio Peixoto" <sergio.peixoto@gmail.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	"Brandon Williams" <bwilliams.eng@gmail.com>,
	git <git@vger.kernel.org>
Subject: Re: [PATCH] attr: do not mark queried macros as unset
Date: Fri, 18 Jan 2019 14:19:55 -0800	[thread overview]
Message-ID: <CAGZ79kaPXQUY=FN3qusc2PNs=o1EiNarcBejOQKiozMSPvEOYw@mail.gmail.com> (raw)
In-Reply-To: <20190118214626.GC28808@sigill.intra.peff.net>

> I dunno. This is why I submitted the initial patch as the simplest fix. ;)
>

The first patch is
Reviewed-by: Stefan Beller <sbeller@google.com>

Diffing across both patches, this seems to be the relevant part:

---8<---
@@ -1111,14 +1116,13 @@ static void collect_some_attrs(const struct
index_state *istate,

        prepare_attr_stack(istate, path, dirlen, &check->stack);
        all_attrs_init(&g_attr_hashmap, check);
-       determine_macros(check->all_attrs, check->stack);

        if (check->nr) {
                rem = 0;
                for (i = 0; i < check->nr; i++) {
                        int n = check->items[i].attr->attr_nr;
                        struct all_attrs_item *item = &check->all_attrs[n];
-                       if (item->macro) {
+                       if (!item->attr->in_stack) {
                                item->value = ATTR__UNSET;
                                rem++;
                        }
@@ -1127,6 +1131,8 @@ static void collect_some_attrs(const struct
index_state *istate,
                        return;
        }

+       determine_macros(check->all_attrs, check->stack);
+
        rem = check->all_attrs_nr;
        fill(path, pathlen, basename_offset, check->stack,
check->all_attrs, rem);
 }
---8<---

which I think is correct.

Maybe we could refactor the big condition (if (check->nr)) to be
its own function and have

    if (!check_overlaps_all_attrs(check))
        return;

instead. The function would allow for a natural place to put a comment
convincing us why the optimisation works as expected. :-)

And after rereading that code, the optimisation checks
if any of the requested attributes in 'check' are touched in
all_attrs, which sounds like a natural optimisation when we assume
that filling in the actual values take a lot of time as the stack
of attribute files might be large.

I think this patch is correct, too.

Stefan

  reply	other threads:[~2019-01-18 22:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-17 15:47 Change on check-attr behavior Sérgio Peixoto
2019-01-17 16:07 ` Jeff King
2019-01-18  9:41   ` Sérgio Peixoto
2019-01-18 16:58     ` Jeff King
2019-01-18 21:34       ` [PATCH] attr: do not mark queried macros as unset Jeff King
2019-01-18 21:46         ` Jeff King
2019-01-18 22:19           ` Stefan Beller [this message]
2019-01-22  7:19             ` Jeff King
2019-01-22  9:50               ` Duy Nguyen
2019-01-22 22:00           ` Junio C Hamano
2019-01-21 10:05         ` Duy Nguyen
2019-01-22  7:21           ` Jeff King
2019-01-22  9:34         ` Duy Nguyen
2019-01-22 21:48         ` Junio C Hamano
2019-01-23  5:40           ` Jeff King

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to='CAGZ79kaPXQUY=FN3qusc2PNs=o1EiNarcBejOQKiozMSPvEOYw@mail.gmail.com' \
    --to=sbeller@google.com \
    --cc=bwilliams.eng@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=sergio.peixoto@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).