Skip to content

Instantly share code, notes, and snippets.

@dmgerman
Created May 19, 2024 08:49
Show Gist options
  • Save dmgerman/1c76743aa36c5d86112123fd333566e2 to your computer and use it in GitHub Desktop.
Save dmgerman/1c76743aa36c5d86112123fd333566e2 to your computer and use it in GitHub Desktop.
Improve performance of org-roam-find-node
(setq dmg-roam-candidates-cache (make-hash-table :test 'equal))
(defun org-roam-node-read--to-candidate (node template)
"Return a minibuffer completion candidate given NODE.
TEMPLATE is the processed template used to format the entry."
(let* ((args (list node template))
(cached-result (gethash args dmg-roam-candidates-cache))
)
(if cached-result
cached-result
(let* ((candidate-main (org-roam-node--format-entry
template
node
(1- (if (bufferp (current-buffer))
(window-width) (frame-width)))))
(result (cons (propertize candidate-main 'node node) node))
)
(progn
(puthash args result dmg-roam-candidates-cache)
result
)
))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment