(performance): avoid path expansion by referencing cache obj (#184)

Prevent needless repeated calls to org-roam-directory-normalized by having a
reference to the cache object that matches the local buffer.

Co-authored-by: Jethro Kuan <jethrokuan95@gmail.com>
This commit is contained in:
Herbert Jones
2020-02-25 10:15:38 -06:00
committed by GitHub
parent 19f16e9c64
commit a8d696e6e8
2 changed files with 34 additions and 22 deletions

View File

@ -68,11 +68,11 @@
(defun org-roam--test-build-cache ()
"Builds the caches synchronously."
(let ((cache (org-roam--build-cache org-roam-directory)))
(org-roam--set-directory-cache
(org-roam-cache :initialized t
:forward-links (plist-get cache :forward)
:backward-links (plist-get cache :backward)
:titles (plist-get cache :titles)))))
(let ((obj (org-roam--get-directory-cache)))
(oset obj initialized t)
(oset obj forward-links (plist-get cache :forward))
(oset obj backward-links (plist-get cache :backward))
(oset obj titles (plist-get cache :titles)))))
;;; Tests
(describe "org-roam--build-cache-async"