From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 35B9F1F4B4 for ; Wed, 23 Dec 2020 01:39:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726885AbgLWBhg (ORCPT ); Tue, 22 Dec 2020 20:37:36 -0500 Received: from pb-smtp2.pobox.com ([64.147.108.71]:65467 "EHLO pb-smtp2.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726844AbgLWBhf (ORCPT ); Tue, 22 Dec 2020 20:37:35 -0500 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 4184C925E9; Tue, 22 Dec 2020 20:36:53 -0500 (EST) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=zFf1SAuZax9GONh4AicaG1/BPB0=; b=A4k9uj 9Us6Q6IbceIOzbsUNVgNvwveAzinkPfCXdi0P6UqQ6bjvm6+9ao1Emp0qIohyf5Y 4XP5vWopsqV65+HC6yQNUDBmYlL9NZ1GQIYn+Dh5plHhK6ccHn2Y2MxDwf8PXitT 0DNHPOVQNLWE9Qo9TamvPOmHqBaIk9Z5DZhs0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=m4bfeDy2d88x++oNDBxlpk907XKE7VpS 628RzS6lHl3Y5ehHgXtfN1lPLjPVItLP1+OokSBl5FzKDClVU7wQJVzKCWs7gUG/ ee1I4OGiCkE1nHAkcQfxjU/cnwg5r076ocORGSdpqcM4PmaMs58ewFnn31r+md2N nzzDa22pxaM= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 361CB925E8; Tue, 22 Dec 2020 20:36:53 -0500 (EST) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [35.196.173.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id B1857925E7; Tue, 22 Dec 2020 20:36:52 -0500 (EST) (envelope-from junio@pobox.com) From: Junio C Hamano To: Rafael Silva Cc: Miriam Rubio , git@vger.kernel.org, Pranit Bauva , Lars Schneider , Christian Couder , Johannes Schindelin , Tanushree Tumane Subject: Re: [PATCH v2 2/7] bisect--helper: reimplement `bisect_replay` shell function in C References: <20201221162743.96056-1-mirucam@gmail.com> <20201221162743.96056-3-mirucam@gmail.com> Date: Tue, 22 Dec 2020 17:36:52 -0800 In-Reply-To: (Rafael Silva's message of "Wed, 23 Dec 2020 01:23:49 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 556B7A24-44BF-11EB-A81D-74DE23BA3BAF-77302942!pb-smtp2.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Rafael Silva writes: > diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c > index b887413d8d..fb15587af8 100644 > --- a/builtin/bisect--helper.c > +++ b/builtin/bisect--helper.c > @@ -988,11 +988,8 @@ static int process_replay_file(FILE *fp, struct bisect_terms *terms) > struct strbuf word = STRBUF_INIT; > int res = 0; > > - while (strbuf_getline(&line, fp) != EOF) { > + while (!res && strbuf_getline(&line, fp) != EOF) > res = process_line(terms, &line, &word); > - if (res) > - break; > - } I do not mind shorter and crisper code, but I somehow find that the original more cleanly expresses the intent. "We'll grab input lines one by one until the input runs out" and "we stop when we see a line that process_line() likes" are conditions that the loop may stop at two logically distinct levels. You can conflate them into a single boolean, making it "unless we found a line the process_line() liked in the previous round, grab the next line but stop when we ran out the input", and it may make the result shorter, but it may be easier to follow by normal readers if we kept them separate, like the original does.