From unknown Thu Aug 14 22:19:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#78779: [PATCH] Avoid rebuilding a static alist inside a loop Resent-From: Manuel Giraud Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 13 Jun 2025 09:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 78779 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 78779@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.174980701022003 (code B ref -1); Fri, 13 Jun 2025 09:31:01 +0000 Received: (at submit) by debbugs.gnu.org; 13 Jun 2025 09:30:10 +0000 Received: from localhost ([127.0.0.1]:40264 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uQ0jf-0005hG-3T for submit@debbugs.gnu.org; Fri, 13 Jun 2025 05:30:08 -0400 Received: from lists.gnu.org ([2001:470:142::17]:41986) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uQ0jb-0005dr-S3 for submit@debbugs.gnu.org; Fri, 13 Jun 2025 05:30:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uQ0jT-0008CQ-HA for bug-gnu-emacs@gnu.org; Fri, 13 Jun 2025 05:29:57 -0400 Received: from ledu-giraud.fr ([51.159.28.247]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uQ0jR-00067h-DX for bug-gnu-emacs@gnu.org; Fri, 13 Jun 2025 05:29:55 -0400 DKIM-Signature: v=1; a=ed25519-sha256; c=simple/simple; s=ed25519; bh=iPUT3DHO At/Y9cuo/FDADJ0O4fJJQ1rcgdUgpYiy5m4=; h=date:subject:to:from; d=ledu-giraud.fr; b=DIeA5tLt5H05o8ndjDxrv0m6HXCMlA+cBnMPtE2hZlUCVBZHAl C+sfJaXD3G4heTjs/qotv0O4EdoZK2Iw/jCw== DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=iPUT3DHOAt/Y9cuo /FDADJ0O4fJJQ1rcgdUgpYiy5m4=; h=date:subject:to:from; d=ledu-giraud.fr; b=AJFTkPgBow/YF7RO0wOnvJ3YTeiVKukuHsq9UxtVJwA3Ze+JJ9 wKMH5EAsVNyXxdEbtEbTQ67EWzutl+uVmtvZ2hhttHyva2WqSzQUrsv2MZlfrQwOaNg/HC XyagY1e/X+YYQ6McvT6C09aayKLGaJmZriYIXHYQY1HovhJHJda63c1E5NoxNo7G+hGx4E mgbmXKJY/oIF2io0pSq1LCuLZlJy59I/TVX0WPxo5RaNZZWLehLFun+upUAUaM5lt7Gnoi q3YQDlLByJzHcu+nEQndhlZb1XAHtjlQcepJO6/W+5zfVwlkKMynlscr4neGCVKejGdYq+ rgDs/t1CVWog== Received: from computer ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id 11449087 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 13 Jun 2025 11:29:48 +0200 (CEST) From: Manuel Giraud Date: Fri, 13 Jun 2025 11:29:47 +0200 Message-ID: <87msacugz8.fsf@ledu-giraud.fr> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=51.159.28.247; envelope-from=manuel@ledu-giraud.fr; helo=ledu-giraud.fr 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) --=-=-= Content-Type: text/plain Tags: patch Hi, This patch avoid constantly rebuilding the same alist inside the main loop for marking diary entries. In GNU Emacs 31.0.50 (build 2, x86_64-unknown-openbsd7.7) of 2025-06-13 built on computer Repository revision: bec823b107ef7d3b51b8e430ccab82c81bd63d24 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101016 System Description: OpenBSD computer 7.7 GENERIC.MP#1 amd64 Configured using: 'configure CC=egcc CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib MAKEINFO=gmakeinfo --prefix=/home/manuel/emacs --bindir=/home/manuel/bin --with-x-toolkit=no --with-toolkit-scroll-bars=no --without-cairo --without-dbus --without-gconf --without-gsettings --without-compress-install' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Avoid-rebuilding-a-static-alist-inside-a-loop.patch >From 34ad15643d718ed0560e899eb5639966afd6e68e Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Fri, 13 Jun 2025 11:25:15 +0200 Subject: [PATCH] Avoid rebuilding a static alist inside a loop * lisp/calendar/diary-lib.el (diary-mark-entries-1): Build months-alist outside of the loop. --- lisp/calendar/diary-lib.el | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el index 4fdf5150cbd..8fb6fadfe4c 100644 --- a/lisp/calendar/diary-lib.el +++ b/lisp/calendar/diary-lib.el @@ -1280,8 +1280,15 @@ diary-mark-entries-1 (month "[0-9]+\\|\\*") (day "[0-9]+\\|\\*") (year "[0-9]+\\|\\*")) - (let* ((case-fold-search t) - marks) + (let ((months-alist (if months (calendar-make-alist months) + (calendar-make-alist + calendar-month-name-array + 1 nil calendar-month-abbrev-array + (mapcar (lambda (e) + (format "%s." e)) + calendar-month-abbrev-array)))) + (case-fold-search t) + marks) (dolist (date-form diary-date-forms) (if (eq (car date-form) 'backup) ; ignore 'backup directive (setq date-form (cdr date-form))) @@ -1363,16 +1370,7 @@ diary-mark-entries-1 (if mm-name (setq mm (if (string-equal mm-name "*") 0 - (cdr (assoc-string - mm-name - (if months (calendar-make-alist months) - (calendar-make-alist - calendar-month-name-array - 1 nil calendar-month-abbrev-array - (mapcar (lambda (e) - (format "%s." e)) - calendar-month-abbrev-array))) - t))))) + (cdr (assoc-string mm-name months-alist t))))) (funcall markfunc mm dd yy marks))))))))) ;;;###cal-autoload -- 2.49.0 --=-=-= Content-Type: text/plain -- Manuel Giraud --=-=-=-- From unknown Thu Aug 14 22:19:50 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Manuel Giraud Subject: bug#78779: closed (Re: bug#78779: [PATCH] Avoid rebuilding a static alist inside a loop) Message-ID: References: <86y0tlig9r.fsf@gnu.org> <87msacugz8.fsf@ledu-giraud.fr> X-Gnu-PR-Message: they-closed 78779 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 78779@debbugs.gnu.org Date: Sat, 21 Jun 2025 09:41:07 +0000 Content-Type: multipart/mixed; boundary="----------=_1750498867-2285-1" This is a multi-part message in MIME format... ------------=_1750498867-2285-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #78779: [PATCH] Avoid rebuilding a static alist inside a loop which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 78779@debbugs.gnu.org. --=20 78779: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D78779 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1750498867-2285-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 78779-done) by debbugs.gnu.org; 21 Jun 2025 09:41:01 +0000 Received: from localhost ([127.0.0.1]:33857 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uSuiZ-0000Zz-K8 for submit@debbugs.gnu.org; Sat, 21 Jun 2025 05:41:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41554) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uSuiX-0000YZ-1G for 78779-done@debbugs.gnu.org; Sat, 21 Jun 2025 05:40:57 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSuiQ-0007Ql-WF; Sat, 21 Jun 2025 05:40:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=vatRqh4m9c2bSPOROy7mmBbPeV4DtAZoCXWLiOQb9wg=; b=HPM2RrPNsjQe Pm0mrx+xe8xehwfJdAaeErgAo6mvJdsDaGPU5+CVPoF0DfgA3fyCJxGlSa7tjMTuL6ZRCyXu0Sdsn 1LhfobIdlz4Ub0SyXCuL+jwQaPRwY/VM9lx9ajlgKBiCNNCOKJgZgekBO+WpGPPfE+ABzjJA5vJkI B+y2nr9q8cOwsTVpIjM+QLiCu5mByQEDZy2axHA9aGjXxC11rHQeBfoK6l3DdOJ4Be2CcdUVJ47hF IbcoHRTLsdJg82xEwn1zRruWgOJyxMF5nngMRJROfrANMi3F1SpV+vxiqWD0SMTVmNE74Ddu4OmR7 ZT309nF2C9eCSAsk3FMD7Q==; Date: Sat, 21 Jun 2025 12:40:48 +0300 Message-Id: <86y0tlig9r.fsf@gnu.org> From: Eli Zaretskii To: Manuel Giraud In-Reply-To: <87msacugz8.fsf@ledu-giraud.fr> (message from Manuel Giraud on Fri, 13 Jun 2025 11:29:47 +0200) Subject: Re: bug#78779: [PATCH] Avoid rebuilding a static alist inside a loop References: <87msacugz8.fsf@ledu-giraud.fr> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78779-done Cc: 78779-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Manuel Giraud > Date: Fri, 13 Jun 2025 11:29:47 +0200 > > This patch avoid constantly rebuilding the same alist inside the main > loop for marking diary entries. Thanks, installed on the master branch, and closing the bug. ------------=_1750498867-2285-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 13 Jun 2025 09:30:10 +0000 Received: from localhost ([127.0.0.1]:40264 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uQ0jf-0005hG-3T for submit@debbugs.gnu.org; Fri, 13 Jun 2025 05:30:08 -0400 Received: from lists.gnu.org ([2001:470:142::17]:41986) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uQ0jb-0005dr-S3 for submit@debbugs.gnu.org; Fri, 13 Jun 2025 05:30:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uQ0jT-0008CQ-HA for bug-gnu-emacs@gnu.org; Fri, 13 Jun 2025 05:29:57 -0400 Received: from ledu-giraud.fr ([51.159.28.247]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uQ0jR-00067h-DX for bug-gnu-emacs@gnu.org; Fri, 13 Jun 2025 05:29:55 -0400 DKIM-Signature: v=1; a=ed25519-sha256; c=simple/simple; s=ed25519; bh=iPUT3DHO At/Y9cuo/FDADJ0O4fJJQ1rcgdUgpYiy5m4=; h=date:subject:to:from; d=ledu-giraud.fr; b=DIeA5tLt5H05o8ndjDxrv0m6HXCMlA+cBnMPtE2hZlUCVBZHAl C+sfJaXD3G4heTjs/qotv0O4EdoZK2Iw/jCw== DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=iPUT3DHOAt/Y9cuo /FDADJ0O4fJJQ1rcgdUgpYiy5m4=; h=date:subject:to:from; d=ledu-giraud.fr; b=AJFTkPgBow/YF7RO0wOnvJ3YTeiVKukuHsq9UxtVJwA3Ze+JJ9 wKMH5EAsVNyXxdEbtEbTQ67EWzutl+uVmtvZ2hhttHyva2WqSzQUrsv2MZlfrQwOaNg/HC XyagY1e/X+YYQ6McvT6C09aayKLGaJmZriYIXHYQY1HovhJHJda63c1E5NoxNo7G+hGx4E mgbmXKJY/oIF2io0pSq1LCuLZlJy59I/TVX0WPxo5RaNZZWLehLFun+upUAUaM5lt7Gnoi q3YQDlLByJzHcu+nEQndhlZb1XAHtjlQcepJO6/W+5zfVwlkKMynlscr4neGCVKejGdYq+ rgDs/t1CVWog== Received: from computer ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id 11449087 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 13 Jun 2025 11:29:48 +0200 (CEST) From: Manuel Giraud To: bug-gnu-emacs@gnu.org Subject: [PATCH] Avoid rebuilding a static alist inside a loop X-Debbugs-Cc: Date: Fri, 13 Jun 2025 11:29:47 +0200 Message-ID: <87msacugz8.fsf@ledu-giraud.fr> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=51.159.28.247; envelope-from=manuel@ledu-giraud.fr; helo=ledu-giraud.fr 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) --=-=-= Content-Type: text/plain Tags: patch Hi, This patch avoid constantly rebuilding the same alist inside the main loop for marking diary entries. In GNU Emacs 31.0.50 (build 2, x86_64-unknown-openbsd7.7) of 2025-06-13 built on computer Repository revision: bec823b107ef7d3b51b8e430ccab82c81bd63d24 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101016 System Description: OpenBSD computer 7.7 GENERIC.MP#1 amd64 Configured using: 'configure CC=egcc CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib MAKEINFO=gmakeinfo --prefix=/home/manuel/emacs --bindir=/home/manuel/bin --with-x-toolkit=no --with-toolkit-scroll-bars=no --without-cairo --without-dbus --without-gconf --without-gsettings --without-compress-install' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Avoid-rebuilding-a-static-alist-inside-a-loop.patch >From 34ad15643d718ed0560e899eb5639966afd6e68e Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Fri, 13 Jun 2025 11:25:15 +0200 Subject: [PATCH] Avoid rebuilding a static alist inside a loop * lisp/calendar/diary-lib.el (diary-mark-entries-1): Build months-alist outside of the loop. --- lisp/calendar/diary-lib.el | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el index 4fdf5150cbd..8fb6fadfe4c 100644 --- a/lisp/calendar/diary-lib.el +++ b/lisp/calendar/diary-lib.el @@ -1280,8 +1280,15 @@ diary-mark-entries-1 (month "[0-9]+\\|\\*") (day "[0-9]+\\|\\*") (year "[0-9]+\\|\\*")) - (let* ((case-fold-search t) - marks) + (let ((months-alist (if months (calendar-make-alist months) + (calendar-make-alist + calendar-month-name-array + 1 nil calendar-month-abbrev-array + (mapcar (lambda (e) + (format "%s." e)) + calendar-month-abbrev-array)))) + (case-fold-search t) + marks) (dolist (date-form diary-date-forms) (if (eq (car date-form) 'backup) ; ignore 'backup directive (setq date-form (cdr date-form))) @@ -1363,16 +1370,7 @@ diary-mark-entries-1 (if mm-name (setq mm (if (string-equal mm-name "*") 0 - (cdr (assoc-string - mm-name - (if months (calendar-make-alist months) - (calendar-make-alist - calendar-month-name-array - 1 nil calendar-month-abbrev-array - (mapcar (lambda (e) - (format "%s." e)) - calendar-month-abbrev-array))) - t))))) + (cdr (assoc-string mm-name months-alist t))))) (funcall markfunc mm dd yy marks))))))))) ;;;###cal-autoload -- 2.49.0 --=-=-= Content-Type: text/plain -- Manuel Giraud --=-=-=-- ------------=_1750498867-2285-1--