Ihor Radchenko writes: > "Christopher M. Miles" writes: > >> 668 28% - org-agenda-prepare-buffers >> ... >> 523 22% - org--tag-add-to-alist > > I have a suspicion where the bottleneck is. > Can you try the attached patch? > > From 1f5cdbd05c7012962ba3f12671805d77f52d836e Mon Sep 17 00:00:00 2001 > Message-Id: <1f5cdbd05c7012962ba3f12671805d77f52d836e.1660373309.git.yantar92@gmail.com> > From: Ihor Radchenko > Date: Sat, 13 Aug 2022 14:45:01 +0800 > Subject: [PATCH] org-agenda-prepare-buffers: Avoid quadratic behavior when > merging tags > > * lisp/org.el (org-agenda-prepare-buffers): Use the shortest list as > the first argument in `org--tag-add-to-alist'. > > `org--tag-add-to-alist' is looping over the first argument. When we > use the accumulated tags as the first argument, each buffer tag will > need to be looped over N_buffers/2 times on average, creating > quadratic complexity. Avoid this. > > Reported in https://orgmode.org/list/62f66552.050a0220.ed346.ac05SMTPIN_ADDED_BROKEN@mx.google.com > --- > lisp/org.el | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lisp/org.el b/lisp/org.el > index 4eef56f45..b21bdf291 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -15196,8 +15196,8 @@ (defun org-agenda-prepare-buffers (files) > (append org-todo-keyword-alist-for-agenda org-todo-key-alist)) > (setq org-tag-alist-for-agenda > (org--tag-add-to-alist > - org-tag-alist-for-agenda > - org-current-tag-alist)) > + org-current-tag-alist > + org-tag-alist-for-agenda)) > ;; Merge current file's tag groups into global > ;; `org-tag-groups-alist-for-agenda'. > (when org-group-tags > -- > 2.35.1 -- [ stardiviner ] I try to make every word tell the meaning that I want to express without misunderstanding. Blog: https://stardiviner.github.io/ IRC(libera.chat, freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3