branch: externals/org
commit b8d01a745be1f234a2400f467732035aa3d7000e
Author: Ihor Radchenko <yanta...@posteo.net>
Commit: Ihor Radchenko <yanta...@posteo.net>

    org-persist: Optimize performance of `org-persist--normalize-associated'
    
    * lisp/org-persist.el (org-persist--get-collection):
    (org-persist-register): Only call `org-persist--normalize-associated'
    from API functions.  Assume that arguments to internal functions are
    normalized.
    (org-persist--normalize-associated): Make inlinable.  Handle nil value fast.
---
 lisp/org-persist.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 603d811778..d96a303820 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -630,7 +630,6 @@ or file-path, (:inode inode), (:hash hash), or or (:key 
key).
 MISC, if non-nil will be appended to the collection.  It must be a plist."
   (unless (and (listp container) (listp (car container)))
     (setq container (list container)))
-  (setq associated (org-persist--normalize-associated associated))
   (when (and misc (or (not (listp misc)) (= 1 (% (length misc) 2))))
     (error "org-persist: Not a plist: %S" misc))
   (or (org-persist--find-index
@@ -667,9 +666,10 @@ When INNER is non-nil, do not try to match as list of 
containers."
 (defvar org-persist--associated-buffer-cache (make-hash-table :weakness 'key)
   "Buffer hash cache.")
 
-(defun org-persist--normalize-associated (associated)
+(defsubst org-persist--normalize-associated (associated)
   "Normalize ASSOCIATED representation into (:type value)."
   (pcase associated
+    (`nil nil)
     ((or (pred stringp) `(:file ,_))
      (unless (stringp associated)
        (setq associated (cadr associated)))
@@ -1009,6 +1009,7 @@ When WRITE-IMMEDIATELY is non-nil, the return value will 
be the same
 with `org-persist-write'."
   (unless org-persist--index (org-persist--load-index))
   (setq container (org-persist--normalize-container container))
+  (setq associated (org-persist--normalize-associated associated))
   (when inherit
     (setq inherit (org-persist--normalize-container inherit))
     (let ((inherited-collection (org-persist--get-collection inherit 
associated))

Reply via email to