]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid rebuilding a static alist inside a loop
authorManuel Giraud <manuel@ledu-giraud.fr>
Fri, 13 Jun 2025 09:25:15 +0000 (11:25 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sun, 22 Jun 2025 08:11:02 +0000 (10:11 +0200)
* lisp/calendar/diary-lib.el (diary-mark-entries-1): Build
months-alist outside of the loop.  (Bug#78779)

(cherry picked from commit d7e55558759dc7be0c38a8c8d508be1909b20aa4)

lisp/calendar/diary-lib.el

index 4fdf5150cbdf2d3e317b99663a1c9c5bb8309d27..8fb6fadfe4c9dc60720761df010538811c5427e5 100644 (file)
@@ -1280,8 +1280,15 @@ function that converts absolute dates to dates of the appropriate type."
        (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 @@ function that converts absolute dates to dates of the appropriate type."
                 (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