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 5/7] Combine unnecessarily separate loops in buffer.c Date: Tue, 23 Mar 2021 23:11:55 -0400 Message-ID: <907d6d027db8c45b4cad3e4749c40928591c62ee.1616554376.git.sbaugh@catern.com> References: Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8393"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Spencer Baugh , Eli Zaretskii , Stefan Monnier To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Mar 24 04:14:02 2021 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 1lOty5-000247-OY for ged-emacs-devel@m.gmane-mx.org; Wed, 24 Mar 2021 04:14:01 +0100 Original-Received: from localhost ([::1]:48642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOty4-00080R-Nj for ged-emacs-devel@m.gmane-mx.org; Tue, 23 Mar 2021 23:14:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOtwS-0006Eg-1G for emacs-devel@gnu.org; Tue, 23 Mar 2021 23:12:20 -0400 Original-Received: from venus.catern.com ([68.183.49.163]:45438) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOtwO-0000la-TA; Tue, 23 Mar 2021 23:12:19 -0400 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=1616555530; bh=0vDneZTgyWseFw4ZcOzKpBllk2sKVM/OXnGL38e/qxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LBdwkC5vLVC6vbbypIUwIRoLtYY4RNLA6koU9GTjz3ut4mgakCfqZCR1X6Thk79Aq LVeATxn0zQNIAWhBovsPnZS9dja3h/ojVDa/txOcBELpK5YvUyqURxBuxNB6thQNPZ GEMXXy6HDZroXY2aq6FuzO6KnQhx5GiWv3vNg6AA= 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 12C522E66F9; Wed, 24 Mar 2021 03:12:10 +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:266908 Archived-At: These loops iterate over the same things with the same check. * src/buffer.c (reset_buffer_local_variables): Combine loops --- src/buffer.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index de3b202ebc..563e5b7180 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1006,7 +1006,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. @@ -1100,10 +1100,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) { @@ -1111,7 +1107,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