From: Jeff King Date: Sat, 12 May 2018 09:22:41 GMT Subject: Re: [PATCH 01/12] blame: use commit-slab for blame suspects instead of commit->util Message-ID: <20180512092241.GD28279@sigill.intra.peff.net> In-Reply-To: <20180512080028.29611-2-pclouds@gmail.com> On Sat, May 12, 2018 at 10:00:17AM +0200, Nguyễn Thái Ngọc Duy wrote: > +define_commit_slab(blame_suspects, struct blame_origin *); > +static struct blame_suspects blame_suspects; > + > +struct blame_origin *get_blame_suspects(struct commit *commit) > +{ > + struct blame_origin **result; > + > + result = blame_suspects_peek(&blame_suspects, commit); > + > + return result ? *result : NULL; > +} Hmm. You need this helper because you want to be able to peek and get a NULL. But that's already what _at() would return, with the only difference that we may extend the slab just to return NULL. I wonder how much it matters in practice. We'd generally be extending the slab to hit every commit anyway in this case, I would think. I suppose it doesn't actually simplify the code that much to do it that way, though. We could get rid of this helper, but the caller would still look like: for (p = *blame_suspects_at(o->commit); p; p = p->next) which is actually slightly uglier than get_blame_suspects(), because we have to do the pointer-dereference ourselves. -Peff