aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorGemini Lasswell2019-07-30 11:56:51 -0700
committerGemini Lasswell2019-09-13 13:43:07 -0700
commit5c40c21a47062782bc983f41e8eeb97180dca693 (patch)
treeebb026a2c26868297c8e4ca6896e491ddf78c085 /lisp
parent2093395dbf8563af38f206950d95f0bc20183b9c (diff)
downloademacs-5c40c21a47062782bc983f41e8eeb97180dca693.tar.gz
emacs-5c40c21a47062782bc983f41e8eeb97180dca693.zip
Improve performance of backtrace printing (bug#36566)
* lisp/emacs-lisp/cl-print.el (cl-print-to-string-with-limit): Reduce print-level and print-length more quickly when the structure being printed is very large.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/cl-print.el21
1 files changed, 11 insertions, 10 deletions
diff --git a/lisp/emacs-lisp/cl-print.el b/lisp/emacs-lisp/cl-print.el
index 5fe3dd1b912..530770128e6 100644
--- a/lisp/emacs-lisp/cl-print.el
+++ b/lisp/emacs-lisp/cl-print.el
@@ -548,21 +548,22 @@ limit."
548 ;; call_debugger (bug#31919). 548 ;; call_debugger (bug#31919).
549 (let* ((print-length (when limit (min limit 50))) 549 (let* ((print-length (when limit (min limit 50)))
550 (print-level (when limit (min 8 (truncate (log limit))))) 550 (print-level (when limit (min 8 (truncate (log limit)))))
551 (delta (when limit 551 (delta-length (when limit
552 (max 1 (truncate (/ print-length print-level)))))) 552 (max 1 (truncate (/ print-length print-level))))))
553 (with-temp-buffer 553 (with-temp-buffer
554 (catch 'done 554 (catch 'done
555 (while t 555 (while t
556 (erase-buffer) 556 (erase-buffer)
557 (funcall print-function value (current-buffer)) 557 (funcall print-function value (current-buffer))
558 ;; Stop when either print-level is too low or the value is 558 (let ((result (- (point-max) (point-min))))
559 ;; successfully printed in the space allowed. 559 ;; Stop when either print-level is too low or the value is
560 (when (or (not limit) 560 ;; successfully printed in the space allowed.
561 (< (- (point-max) (point-min)) limit) 561 (when (or (not limit) (< result limit) (<= print-level 2))
562 (= print-level 2)) 562 (throw 'done (buffer-string)))
563 (throw 'done (buffer-string))) 563 (let* ((ratio (/ result limit))
564 (cl-decf print-level) 564 (delta-level (max 1 (min (- print-level 2) ratio))))
565 (cl-decf print-length delta)))))) 565 (cl-decf print-level delta-level)
566 (cl-decf print-length (* delta-length delta-level)))))))))
566 567
567(provide 'cl-print) 568(provide 'cl-print)
568;;; cl-print.el ends here 569;;; cl-print.el ends here