Subject: Re: [PATCH] commit-reach: stop sorting in paint_down_to_common()

From: Jeff King <[email-masked]>
Date: Fri, 29 May 2026 15:04:53 -0400

On Fri, May 29, 2026 at 05:32:58PM +0200, René Scharfe wrote:

> > Seems like an easy win. If some of the callers do not even look at the
> > result, could we avoid building it at all in those cases (e.g., by
> > passing in a NULL result pointer)?
> 
> Yes, at the cost of adding NULL checks to paint_down_to_common().  Which
> is probably worth it.

Yeah. I thought it was only one line (where we append to "tail"), but
there are a couple spots where "result" is referenced directly.

Another fun fact: it looks like paint_down_to_common() makes sure to
clean up the output list before returning an error. But the callers do
so, too, which is redundant. That would go away if they just passed in
NULL. :)

-Peff