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:
parent
4080938d60
commit
97d4d927f2
18
lisp/org.el
18
lisp/org.el
@ -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))))
|
||||
|
Loading…
Reference in New Issue
Block a user