emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-26 e5bff69: Revert last change in 'shr-descend'


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-26 e5bff69: Revert last change in 'shr-descend'
Date: Fri, 6 Oct 2017 08:43:29 -0400 (EDT)

branch: emacs-26
commit e5bff696bcf5f54d2db9bcc8c5ce93083ac0a0d3
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Revert last change in 'shr-descend'
    
    * lisp/net/shr.el (shr-descend): Revert the part of the last
    change which introduced calls to shr-indirect-call into this
    function.  Add a comment explaining the rationale for that.
    (Bug#28402)
---
 lisp/net/shr.el | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index fe5197b..260ada5 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -483,7 +483,11 @@ size, and full-buffer size."
           (apply 'shr-generic dom args)))))
 
 (defun shr-descend (dom)
-  (let ((tag-name (dom-tag dom))
+  (let ((function
+         (intern (concat "shr-tag-" (symbol-name (dom-tag dom))) obarray))
+        ;; Allow other packages to override (or provide) rendering
+        ;; of elements.
+        (external (cdr (assq (dom-tag dom) shr-external-rendering-functions)))
        (style (dom-attr dom 'style))
        (shr-stylesheet shr-stylesheet)
        (shr-depth (1+ shr-depth))
@@ -498,7 +502,17 @@ size, and full-buffer size."
          (setq style nil)))
       ;; If we have a display:none, then just ignore this part of the DOM.
       (unless (equal (cdr (assq 'display shr-stylesheet)) "none")
-       (shr-indirect-call tag-name dom)
+        ;; We don't use shr-indirect-call here, since shr-descend is
+        ;; the central bit of shr.el, and should be as fast as
+        ;; possible.  Having one more level of indirection with its
+        ;; negative effect on performance is deemed unjustified in
+        ;; this case.
+        (cond (external
+               (funcall external dom))
+              ((fboundp function)
+               (funcall function dom))
+              (t
+               (shr-generic dom)))
        (when (and shr-target-id
                   (equal (dom-attr dom 'id) shr-target-id))
          ;; If the element was empty, we don't have anything to put the



reply via email to

[Prev in Thread] Current Thread [Next in Thread]