Forráskód Böngészése

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.
Bastien Guerry 12 éve
szülő
commit
0de96daa95
1 módosított fájl, 21 hozzáadás és 20 törlés
  1. 21 20
      lisp/org.el

+ 21 - 20
lisp/org.el

@@ -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
 	  ;; retrieve it, but specify the wanted property
 	  (cdr (assoc property (org-entry-properties nil 'special property)))
-	(let* ((range (org-get-property-block))
-	       (props (list (or (assoc property org-file-properties)
-				(assoc property org-global-properties)
-				(assoc property org-global-properties-fixed))))
-	       (ap (lambda (key)
-		     (when (re-search-forward
-			    (org-re-property key) (cdr range) t)
-		       (setq props
-			     (org-update-property-plist
-			      key
-			      (if (match-end 1)
-				  (org-match-string-no-properties 1) "")
-			      props)))))
-	       val)
-	  (when (and range (goto-char (car range)))
-	    (funcall ap property)
-	    (goto-char (car range))
-	    (while (funcall ap (concat property "+")))
-	    (setq val (cdr (assoc property props)))
-	    (when val (if literal-nil val (org-not-nil val)))))))))
+	(let ((range (org-get-property-block)))
+	  (when (and range (not (eq (car range) (cdr range))))
+	    (let* ((props (list (or (assoc property org-file-properties)
+				    (assoc property org-global-properties)
+				    (assoc property org-global-properties-fixed))))
+		   (ap (lambda (key)
+			 (when (re-search-forward
+				(org-re-property key) (cdr range) t)
+			   (setq props
+				 (org-update-property-plist
+				  key
+				  (if (match-end 1)
+				      (org-match-string-no-properties 1) "")
+				  props)))))
+		   val)
+	      (goto-char (car range))
+	      (funcall ap property)
+	      (goto-char (car range))
+	      (while (funcall ap (concat property "+")))
+	      (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)
   "Check if there is a property fixing the value of VAR.