From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 192BC1E1C11 for ; Tue, 14 Jul 2026 16:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784047217; cv=none; b=tczyNWXX76Q0d2VnE7RDWvdvD8+/CCXRGtD0U7mNH1d05XBuAYJMufNkh0Xo7kmVifrFQmPjG9RpN1idFlJCJaoGHFwqvgLPcaoITr7iKcHOf1uuVZxX1mj1M0EfiT1bS99j6PsA8bHOi5AzVJkeu3Sa9jVwaTQ8DPBiolIlrSw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784047217; c=relaxed/simple; bh=LM2s7j3nM1MkPtnScNkWD5ZHSjBy6izqWJynxZUrFCo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=QCWhThLi6MP10paFElRGvMN+8PHv4Hoz/evGZFfrVdUdntJqItfdE3QTXUbYx6q8qWhghg3aph7Uyb9fqaxq+WCT8Pw/Eyc4hDNC5L6eNQ5CJCeUxBNtcnyf2oSPE5S4FTmG0Zh2xqOFCkWaokQNs+gstKmAExZkaHytH51HwbE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=l7A1Y7OT; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Asqhqlej; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="l7A1Y7OT"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Asqhqlej" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id 3806E1400155; Tue, 14 Jul 2026 12:40:14 -0400 (EDT) Received: from phl-frontend-02 ([10.202.2.161]) by phl-compute-06.internal (MEProxy); Tue, 14 Jul 2026 12:40:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1784047214; x=1784133614; bh=LOT0TNd2tQ4AJkWVNX6DJlVd/jEL14nQjfKt6DXA+PQ=; b= l7A1Y7OTasgcj0vZc+5rvsbsQkoCOsAtoxXxw0jHIicqD12qoFg64ZIcpaKvznyR Xn3vcBsCvzrH0cXrGgvdmvyIR+9G9DCRnDu7MROgHVArVl750v08Pii2CP5hc2yf WzYn9FDKpT4h9vgHJASuMGLEPfK8N74JPG9zCnSWqiqpVq3wbA8ayikpubFvXPN+ EHKxhTBAUQrBzrm3AtiThpZKMiAi6xRWm061TZ6W/d5kR9hjT+7RCM/5QHaPxsAz FefJSga1YSOL2mitD2ngkIrKR+SZ34/39d/YFqR3adeRldNzAu6IywRewzpAgk4M JjTTisG/7DyyYeip2dnpYQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1784047214; x= 1784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P6VQEZhbGqC5dm8XYxedJjYAilLL133HwR6EH6lZ7kmFlZl4u55stCHli2fg X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 14 Jul 2026 12:40:13 -0400 (EDT) From: Junio C Hamano To: =?utf-8?Q?Ren=C3=A9?= Scharfe Cc: Git List Subject: Re: [PATCH] strbuf: avoid redundant reset in strbuf_getwholeline() In-Reply-To: (=?utf-8?Q?=22R?= =?utf-8?Q?en=C3=A9?= Scharfe"'s message of "Tue, 14 Jul 2026 10:45:59 +0200") References: Date: Tue, 14 Jul 2026 09:40:12 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit René Scharfe writes: > The HAVE_GETDELIM variant of strbuf_getwholeline() calls strbuf_reset() > on the strbuf before handing it over to getdelim(3). This is > unnecessary: > > - getdelim(3) doesn't care whether the old buffer contents is > NUL-terminated and has no access to ->len, > - on success getdelim(3) NUL-terminates the buffer and we set ->len, > - on error we either call strbuf_init() or strbuf_reset(). > > Remove the superfluous preparatory call. > > Signed-off-by: René Scharfe > --- > strbuf.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/strbuf.c b/strbuf.c > index 764b629927..44955669e8 100644 > --- a/strbuf.c > +++ b/strbuf.c > @@ -646,8 +646,6 @@ int strbuf_getwholeline(struct strbuf *sb, FILE *fp, int term) > if (feof(fp)) > return EOF; > > - strbuf_reset(sb); > - This is well explained and makes perfect sense. Thanks. Will apply and mark for 'next'. > /* Translate slopbuf to NULL, as we cannot call realloc on it */ > if (!sb->alloc) > sb->buf = NULL;