1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-29 07:58:21 +00:00

org-agenda-prepare-buffers: Avoid excessive memory allocation

* lisp/org.el (org-agenda-prepare-buffers): Avoid creating huge lists
when computing `org-todo-keywords-for-agenda',
`org-done-keywords-for-agenda', and
`org-todo-keyword-alist-for-agenda'.  Instead of using `append' in
every single agenda file + `org-uniquify' on a giant lists at the end,
check and add unique list elements in place.

This patch reduces load on Emacs GC when the number of agenda files is
large.
This commit is contained in:
Ihor Radchenko 2022-08-18 19:10:59 +08:00
parent 4080938d60
commit 97d4d927f2
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B

View File

@ -15192,12 +15192,16 @@ When a buffer is unmodified, it is just killed. When modified, it is saved
(org-refresh-effort-properties)))
(or (memq 'appt org-agenda-ignore-properties)
(org-refresh-properties "APPT_WARNTIME" 'org-appt-warntime))
(setq org-todo-keywords-for-agenda
(append org-todo-keywords-for-agenda org-todo-keywords-1))
(setq org-done-keywords-for-agenda
(append org-done-keywords-for-agenda org-done-keywords))
(dolist (el org-todo-keywords-1)
(unless (member el org-todo-keywords-for-agenda)
(push el org-todo-keywords-for-agenda)))
(dolist (el org-done-keywords)
(unless (member el org-done-keywords-for-agenda)
(push el org-done-keywords-for-agenda)))
(setq org-todo-keyword-alist-for-agenda
(append org-todo-keyword-alist-for-agenda org-todo-key-alist))
(org--tag-add-to-alist
org-todo-key-alist
org-todo-keyword-alist-for-agenda))
(setq org-tag-alist-for-agenda
(org--tag-add-to-alist
org-current-tag-alist
@ -15210,10 +15214,6 @@ When a buffer is unmodified, it is just killed. When modified, it is saved
(if old
(setcdr old (org-uniquify (append (cdr old) (cdr alist))))
(push alist org-tag-groups-alist-for-agenda)))))))))
(setq org-todo-keywords-for-agenda
(org-uniquify org-todo-keywords-for-agenda))
(setq org-todo-keyword-alist-for-agenda
(org-uniquify org-todo-keyword-alist-for-agenda))))
;; Refresh the menu once after loading all the agenda buffers.
(when org-agenda-file-menu-enabled
(org-install-agenda-files-menu))))