org.el (org-entry-get): Speed up by let-binding some variables only if needed

* org.el (org-entry-get): Speed up by let-binding some
variables only if needed.  Also fix a bug: consider an empty
drawer as no drawer.

Thanks to William Léchelle for reporting this.
This commit is contained in:
Bastien Guerry 2013-01-07 18:18:27 +01:00
parent c8bfd50223
commit 0de96daa95
1 changed files with 21 additions and 20 deletions

View File

@ -14485,26 +14485,27 @@ when a \"nil\" value can supersede a non-nil value higher up the hierarchy."
;; We need a special property. Use `org-entry-properties' to ;; We need a special property. Use `org-entry-properties' to
;; retrieve it, but specify the wanted property ;; retrieve it, but specify the wanted property
(cdr (assoc property (org-entry-properties nil 'special property))) (cdr (assoc property (org-entry-properties nil 'special property)))
(let* ((range (org-get-property-block)) (let ((range (org-get-property-block)))
(props (list (or (assoc property org-file-properties) (when (and range (not (eq (car range) (cdr range))))
(assoc property org-global-properties) (let* ((props (list (or (assoc property org-file-properties)
(assoc property org-global-properties-fixed)))) (assoc property org-global-properties)
(ap (lambda (key) (assoc property org-global-properties-fixed))))
(when (re-search-forward (ap (lambda (key)
(org-re-property key) (cdr range) t) (when (re-search-forward
(setq props (org-re-property key) (cdr range) t)
(org-update-property-plist (setq props
key (org-update-property-plist
(if (match-end 1) key
(org-match-string-no-properties 1) "") (if (match-end 1)
props))))) (org-match-string-no-properties 1) "")
val) props)))))
(when (and range (goto-char (car range))) val)
(funcall ap property) (goto-char (car range))
(goto-char (car range)) (funcall ap property)
(while (funcall ap (concat property "+"))) (goto-char (car range))
(setq val (cdr (assoc property props))) (while (funcall ap (concat property "+")))
(when val (if literal-nil val (org-not-nil val))))))))) (setq val (cdr (assoc property props)))
(when val (if literal-nil val (org-not-nil val))))))))))
(defun org-property-or-variable-value (var &optional inherit) (defun org-property-or-variable-value (var &optional inherit)
"Check if there is a property fixing the value of VAR. "Check if there is a property fixing the value of VAR.