From: Junio C Hamano Date: Wed, 06 Mar 2013 15:30:08 GMT Subject: Re: [PATCH v2 1/4] commit.c: add clear_commit_marks_many() Message-ID: <7vd2vcsfzz.fsf@alter.siamese.dyndns.org> In-Reply-To: <20130306083037.GA2018@sigill.intra.peff.net> Jeff King writes: > On Tue, Mar 05, 2013 at 02:47:16PM -0800, Junio C Hamano wrote: > >> clear_commit_marks(struct commit *, unsigned) only can clear flag >> bits starting from a single commit; introduce an API to allow >> feeding an array of commits, so that flag bits can be cleared from >> commits reachable from any of them with a single traversal. > > Out of curiosity, is that actually measurably more efficient? > > Since we stop traversing a commit's parents when we see it does not have > any of the flags we are clearing, we should visit most commits once. The > exception is ones that we hit by multiple paths. But that should > be the same whether it is done as part of a single traversal or > multiple; in each case, we hit the commit and say "Oh, already cleared; > do not add it to the parents list". > > So I would expect it to have little to no impact on performance. I > still think it is a sane interface change; I was just curious from the > commit message whether there could be a performance impact. I agree that the log message should end with "with a single API call." to clarify that this is more about eliminating the code overhead (the caller having to loop over an array of things) than about runtime overhead.