git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] attr: do not mark queried macros as unset

From
Stefan Beller <sbeller@google.com>
Date
Jan 18, 2019, 22:19 UTC
Message-ID
<CAGZ79kaPXQUY=FN3qusc2PNs=o1EiNarcBejOQKiozMSPvEOYw@mail.gmail.com>
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
Previous: Jeff KingNext: Jeff King
Message 7 of 15 in “Change on check-attr behavior”
  1. Sérgio PeixotoJan 17, 2019
  2. Jeff KingJan 17, 2019
  3. Sérgio PeixotoJan 18, 2019
  4. Jeff KingJan 18, 2019
  5. attr: do not mark queried macros as unsetJeff King, Jan 18, 2019
  6. Jeff KingJan 18, 2019
  7. Stefan BellerJan 18, 2019
  8. Jeff KingJan 22, 2019
  9. Duy NguyenJan 22, 2019
  10. Junio C HamanoJan 22, 2019
  11. Duy NguyenJan 21, 2019
  12. Jeff KingJan 22, 2019
  13. Duy NguyenJan 22, 2019
  14. Junio C HamanoJan 22, 2019
  15. Jeff KingJan 23, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.