From 01e06d90f27b8204e69508351b7fca9c03e7af32 Mon Sep 17 00:00:00 2001 From: Allen Li Date: Wed, 23 Aug 2023 00:22:06 -0700 Subject: [PATCH] org-element: Raise gc-cons-threshold for org-element-cache-map This garbage collects many times when calling org-get-buffer-tags (such as during tag completion) in a large file with many tags. Raise gc-cons-threshold as this may affect other callers in large files. Note that org-element-parse-buffer also raises gc-cons-threshold as a precedent. This has no effect on most callers and increases performance for extreme cases. * lisp/org-element.el (org-element-cache-map): Raise gc-cons-threshold. --- lisp/org-element.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index b2c5b0402..694a4f43f 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -7568,7 +7568,8 @@ the cache." (let ((mk (make-marker))) (set-marker mk to-pos) (setq to-pos mk))) - (let (;; Bind variables used inside loop to avoid memory + (let ((gc-cons-threshold #x40000000) + ;; Bind variables used inside loop to avoid memory ;; re-allocation on every iteration. ;; See https://emacsconf.org/2021/talks/faster/ tmpnext-start tmpparent tmpelement) -- 2.41.0