From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.devel Subject: [PATCH v2 08/16] Combine unnecessarily separate loops in buffer.c Date: Sat, 21 Nov 2020 21:34:37 -0500 Message-ID: References: <20201119153814.17541-1-sbaugh@catern.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24532"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Spencer Baugh , Arnold Noronha , Stefan Monnier , Dmitry Gutov To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 22 03:38:39 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kgfGw-0006Ge-Ha for ged-emacs-devel@m.gmane-mx.org; Sun, 22 Nov 2020 03:38:38 +0100 Original-Received: from localhost ([::1]:50600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgfGv-0005SP-J3 for ged-emacs-devel@m.gmane-mx.org; Sat, 21 Nov 2020 21:38:37 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgfDM-0000OW-1d for emacs-devel@gnu.org; Sat, 21 Nov 2020 21:34:56 -0500 Original-Received: from venus.catern.com ([68.183.49.163]:60150) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgfDI-0007JC-Oe for emacs-devel@gnu.org; Sat, 21 Nov 2020 21:34:55 -0500 Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235; helo=localhost; envelope-from=sbaugh@catern.com; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail; t=1606012492; bh=W6RFREL9MgcpLkMb1YXMb9Y9ht4+eVL2SY1ENGPDPA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ai6+2wQp/NYToECLX8I5Za/LSRkSUVKY5eVLCK2V+nOIgRyFI+6pkwvyhbR/i2BVF hVA0OFKcasjugPqYVt2aiMGL5PPTHYJ/4Ds+9/LGGdUy6x3cDYrBnU/W1GWgoefMK0 wCb41VHMWHXC3Q/GJljnf7Wu9/b5q8TGUDfwmrPQ= Original-Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235]) by venus.catern.com (Postfix) with ESMTPSA id 3889B2DDDCF; Sun, 22 Nov 2020 02:34:52 +0000 (UTC) X-Mailer: git-send-email 2.28.0 In-Reply-To: Received-SPF: pass client-ip=68.183.49.163; envelope-from=sbaugh@catern.com; helo=venus.catern.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:259580 Archived-At: These loops iterate over the same things with the same check. --- src/buffer.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index a0bcbf38e5..5333db73bd 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -984,7 +984,7 @@ reset_buffer (register struct buffer *b) static void reset_buffer_local_variables (struct buffer *b, bool permanent_too) { - int offset, i; + int offset; /* Reset the major mode to Fundamental, together with all the things that depend on the major mode. @@ -1078,10 +1078,6 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too) } } - for (i = 0; i < last_per_buffer_idx; ++i) - if (permanent_too || buffer_permanent_local_flags[i] == 0) - SET_PER_BUFFER_VALUE_P (b, i, 0); - /* For each slot that has a default value, copy that into the slot. */ FOR_EACH_PER_BUFFER_OBJECT_AT (offset) { @@ -1089,7 +1085,10 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too) if ((idx > 0 && (permanent_too || buffer_permanent_local_flags[idx] == 0))) - set_per_buffer_value (b, offset, per_buffer_default (offset)); + { + SET_PER_BUFFER_VALUE_P (b, idx, 0); + set_per_buffer_value (b, offset, per_buffer_default (offset)); + } } } -- 2.28.0