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-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS,URIBL_CSS, URIBL_CSS_A 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 BD15E1F953 for ; Fri, 29 Oct 2021 22:51:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231539AbhJ2Wxa (ORCPT ); Fri, 29 Oct 2021 18:53:30 -0400 Received: from pb-smtp20.pobox.com ([173.228.157.52]:64673 "EHLO pb-smtp20.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbhJ2Wx1 (ORCPT ); Fri, 29 Oct 2021 18:53:27 -0400 Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 27E7716BD77; Fri, 29 Oct 2021 18:50:58 -0400 (EDT) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=PKSjdJQBaHIfhKTYdGTFoy4X4WCODvfamb9fzT h3gyA=; b=gxTuEGSVDyQgCpMPNuCSfiNTUVFvVnBtBtwYRQHAcubgZgVB3lxuWO JCiMfP2ASCxBPDFy066yhe/bTXO3KbJKFMDe3YCzgZIBdCkESE7qC1TKRUMER14G XfJgnVAl5tOLuwebKbw5w0ZkxjEFLpUQOBhlQdndM031S6unyB/lk= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 20EDC16BD76; Fri, 29 Oct 2021 18:50:58 -0400 (EDT) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [104.133.2.91]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id CF2F516BD75; Fri, 29 Oct 2021 18:50:54 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: "Johannes Schindelin via GitGitGadget" Cc: git@vger.kernel.org, Carlo Arenas , "brian m. carlson" , Johannes Schindelin Subject: Re: [PATCH v3 2/8] test-tool genzeros: generate large amounts of data more efficiently References: <052197200141c321118b7766f5615a61f951e59f.1635515959.git.gitgitgadget@gmail.com> Date: Fri, 29 Oct 2021 15:50:53 -0700 In-Reply-To: <052197200141c321118b7766f5615a61f951e59f.1635515959.git.gitgitgadget@gmail.com> (Johannes Schindelin via GitGitGadget's message of "Fri, 29 Oct 2021 13:59:13 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: AC877DEA-390A-11EC-A747-F327CE9DA9D6-77302942!pb-smtp20.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org "Johannes Schindelin via GitGitGadget" writes: > @@ -12,9 +15,19 @@ int cmd__genzeros(int argc, const char **argv) > > count = argc > 1 ? strtoimax(argv[1], NULL, 0) : -1; > > - while (count < 0 || count--) { > - if (putchar(0) == EOF) > + /* Writing out individual NUL bytes is slow... */ > + while (count < 0) > + if (write(1, zeros, ARRAY_SIZE(zeros)) < 0) > return -1; > + > + while (count > 0) { > + n = write(1, zeros, count < ARRAY_SIZE(zeros) ? > + count : ARRAY_SIZE(zeros)); > + > + if (n < 0) > + return -1; > + > + count -= n; > } > > return 0; This round looks OK to me.