mirror of
https://github.com/org-roam/org-roam
synced 2025-08-03 12:27:23 -05:00
(perf): Deprecate link :outline properties
As it happens, turning sexps into strings is one of the computationally expensive steps in EmacSQL. With an enormous number of links in the database, that's a lot of (:outline nil) to stringify into "(:outline nil)". Its only use was in org-roam-node-insert-section, where the information is very cheap to reconstruct. It's already in one of the other arguments! This has passed unnoticed because org-roam-db-sync has other performance tarpits, but it will probably be noticed eventually after those get fixed.
This commit is contained in:
committed by
Dustin Farris
parent
0037daaf3e
commit
db4170a459
@ -108,7 +108,7 @@ ROAM_REFS."
|
|||||||
:type '(alist))
|
:type '(alist))
|
||||||
|
|
||||||
;;; Variables
|
;;; Variables
|
||||||
(defconst org-roam-db-version 18)
|
(defconst org-roam-db-version 19)
|
||||||
|
|
||||||
(defvar org-roam-db--connection (make-hash-table :test #'equal)
|
(defvar org-roam-db--connection (make-hash-table :test #'equal)
|
||||||
"Database connection to Org-roam database.")
|
"Database connection to Org-roam database.")
|
||||||
@ -214,7 +214,7 @@ The query is expected to be able to fail, in this situation, run HANDLER."
|
|||||||
(source :not-null)
|
(source :not-null)
|
||||||
(dest :not-null)
|
(dest :not-null)
|
||||||
(type :not-null)
|
(type :not-null)
|
||||||
(properties :not-null)]
|
properties]
|
||||||
(:foreign-key [source] :references nodes [id] :on-delete :cascade)))))
|
(:foreign-key [source] :references nodes [id] :on-delete :cascade)))))
|
||||||
|
|
||||||
(defconst org-roam-db--table-indices
|
(defconst org-roam-db--table-indices
|
||||||
@ -507,11 +507,8 @@ INFO is the org-element parsed buffer."
|
|||||||
(path (if (not option) path
|
(path (if (not option) path
|
||||||
(substring path 0 (match-beginning 0))))
|
(substring path 0 (match-beginning 0))))
|
||||||
(source (org-roam-id-at-point))
|
(source (org-roam-id-at-point))
|
||||||
(properties (list :outline (ignore-errors
|
(properties (when option
|
||||||
;; This can error if link is not under any headline
|
(list :search-option option))))
|
||||||
(org-get-outline-path 'with-self 'use-cache))))
|
|
||||||
(properties (if option (plist-put properties :search-option option)
|
|
||||||
properties)))
|
|
||||||
;; For Org-ref links, we need to split the path into the cite keys
|
;; For Org-ref links, we need to split the path into the cite keys
|
||||||
(when (and source path)
|
(when (and source path)
|
||||||
(if (and (boundp 'org-ref-cite-types)
|
(if (and (boundp 'org-ref-cite-types)
|
||||||
@ -533,9 +530,7 @@ INFO is the org-element parsed buffer."
|
|||||||
(goto-char (org-element-property :begin citation))
|
(goto-char (org-element-property :begin citation))
|
||||||
(let ((key (org-element-property :key citation))
|
(let ((key (org-element-property :key citation))
|
||||||
(source (org-roam-id-at-point))
|
(source (org-roam-id-at-point))
|
||||||
(properties (list :outline (ignore-errors
|
(properties nil))
|
||||||
;; This can error if link is not under any headline
|
|
||||||
(org-get-outline-path 'with-self 'use-cache)))))
|
|
||||||
(when (and source key)
|
(when (and source key)
|
||||||
(org-roam-db-query
|
(org-roam-db-query
|
||||||
[:insert :into citations
|
[:insert :into citations
|
||||||
|
@ -369,7 +369,7 @@ run at `post-command-hook'."
|
|||||||
(node :initform nil))
|
(node :initform nil))
|
||||||
"A `magit-section' used by `org-roam-mode' to outline NODE in its own heading.")
|
"A `magit-section' used by `org-roam-mode' to outline NODE in its own heading.")
|
||||||
|
|
||||||
(cl-defun org-roam-node-insert-section (&key source-node point properties)
|
(cl-defun org-roam-node-insert-section (&key source-node point _properties)
|
||||||
"Insert section for a link from SOURCE-NODE to some other node.
|
"Insert section for a link from SOURCE-NODE to some other node.
|
||||||
The other node is normally `org-roam-buffer-current-node'.
|
The other node is normally `org-roam-buffer-current-node'.
|
||||||
|
|
||||||
@ -393,7 +393,9 @@ the same time:
|
|||||||
other node) at POINT. Acts a child section of the previous
|
other node) at POINT. Acts a child section of the previous
|
||||||
one."
|
one."
|
||||||
(magit-insert-section section (org-roam-node-section)
|
(magit-insert-section section (org-roam-node-section)
|
||||||
(let ((outline (if-let ((outline (plist-get properties :outline)))
|
(let ((outline (if-let ((outline (append
|
||||||
|
(org-roam-node-olp source-node)
|
||||||
|
(list (org-roam-node-title source-node)))))
|
||||||
(mapconcat #'org-link-display-format outline " > ")
|
(mapconcat #'org-link-display-format outline " > ")
|
||||||
"Top")))
|
"Top")))
|
||||||
(insert (concat (propertize (org-roam-node-title source-node)
|
(insert (concat (propertize (org-roam-node-title source-node)
|
||||||
@ -534,8 +536,7 @@ SECTION-HEADING is the string used as a heading for the backlink section."
|
|||||||
(funcall show-backlink-p backlink)))
|
(funcall show-backlink-p backlink)))
|
||||||
(org-roam-node-insert-section
|
(org-roam-node-insert-section
|
||||||
:source-node (org-roam-backlink-source-node backlink)
|
:source-node (org-roam-backlink-source-node backlink)
|
||||||
:point (org-roam-backlink-point backlink)
|
:point (org-roam-backlink-point backlink))))
|
||||||
:properties (org-roam-backlink-properties backlink))))
|
|
||||||
(insert ?\n))))
|
(insert ?\n))))
|
||||||
|
|
||||||
;;;; Reflinks
|
;;;; Reflinks
|
||||||
@ -590,8 +591,7 @@ Sorts by title."
|
|||||||
(dolist (reflink reflinks)
|
(dolist (reflink reflinks)
|
||||||
(org-roam-node-insert-section
|
(org-roam-node-insert-section
|
||||||
:source-node (org-roam-reflink-source-node reflink)
|
:source-node (org-roam-reflink-source-node reflink)
|
||||||
:point (org-roam-reflink-point reflink)
|
:point (org-roam-reflink-point reflink)))
|
||||||
:properties (org-roam-reflink-properties reflink)))
|
|
||||||
(insert ?\n))))
|
(insert ?\n))))
|
||||||
|
|
||||||
;;;; Grep
|
;;;; Grep
|
||||||
|
Reference in New Issue
Block a user