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.bugs Subject: bug#48264: [PATCH v4 04/14] Combine unnecessarily separate loops in buffer.c Date: Fri, 7 May 2021 22:08:55 -0400 Message-ID: <20210508020905.13583-6-sbaugh@catern.com> References: <20210506213346.9730-1-sbaugh@catern.com> <20210508020905.13583-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="2217"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Spencer Baugh To: 48264@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat May 08 04:40:15 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1lfCt5-0000U5-LL for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 08 May 2021 04:40:15 +0200 Original-Received: from localhost ([::1]:48522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lfCt4-0001VH-Bm for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 May 2021 22:40:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lfCPt-0001KT-LC for bug-gnu-emacs@gnu.org; Fri, 07 May 2021 22:10:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35647) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lfCPs-0007X0-BK for bug-gnu-emacs@gnu.org; Fri, 07 May 2021 22:10:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lfCPs-0006Up-7Y for bug-gnu-emacs@gnu.org; Fri, 07 May 2021 22:10:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 08 May 2021 02:10:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48264 X-GNU-PR-Package: emacs Original-Received: via spool by 48264-submit@debbugs.gnu.org id=B48264.162043976124802 (code B ref 48264); Sat, 08 May 2021 02:10:04 +0000 Original-Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:21 +0000 Original-Received: from localhost ([127.0.0.1]:47158 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfCPA-0006Ro-Db for submit@debbugs.gnu.org; Fri, 07 May 2021 22:09:20 -0400 Original-Received: from venus.catern.com ([68.183.49.163]:47906) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfCP7-0006RB-7X for 48264@debbugs.gnu.org; Fri, 07 May 2021 22:09:17 -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=1620439757; bh=NU4eHuHwUlDI3TWKg5+NjNY0tOC+pHyFCBJ/jFbcXa8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QFAf3i5Fnq7aTyp1e3KlesXXTl8D/Q6BTDD4GngqMaLSQNiDgmo9GbI4v1NkbAiGU +szPuCqIGSpEYxd2HQOfwaXSRajdSda7NKmWs/HqO73UrgYCno2LbclBKiUXeroVNQ qhlI/px1uzxFJdScIMMc5loRn6quazc/i4TiPzBQ= 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 F2B612E982B; Sat, 8 May 2021 02:09:16 +0000 (UTC) X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210508020905.13583-1-sbaugh@catern.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:205969 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 efc85bf378..4336e10a27 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 ((BVAR_HAS_DEFAULT_VALUE_P (offset) && (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.31.1