From: Juri Linkov Date: Wed, 4 Dec 2024 18:38:41 +0000 (+0200) Subject: * lisp/tab-line.el (tab-line-tabs-fixed-window-buffers): More optimizations. X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4ec51cba6ef264f0567096b4f7596fbb71a304d2;p=emacs.git * lisp/tab-line.el (tab-line-tabs-fixed-window-buffers): More optimizations. Use :size arg of 'make-hash-table' as a hint how many buffers the table will have. Add ':in-place t' to 'sort'. (cherry picked from commit 25b4bf7fcd75564f23b2e60e29e8ff7354186371) --- diff --git a/lisp/tab-line.el b/lisp/tab-line.el index f0a3fb9d890..43f26ba1d36 100644 --- a/lisp/tab-line.el +++ b/lisp/tab-line.el @@ -555,12 +555,15 @@ This means that switching to a buffer previously shown in the same window will keep the same order of tabs that was before switching. And newly displayed buffers are added to the end of the tab line." (let* ((old-buffers (window-parameter nil 'tab-line-buffers)) - (buffer-positions (let ((index-table (make-hash-table :test 'eq))) + (buffer-positions (let ((index-table (make-hash-table + :size (length old-buffers) + :test #'eq))) (seq-do-indexed (lambda (buf idx) (puthash buf idx index-table)) old-buffers) index-table)) (new-buffers (sort (tab-line-tabs-window-buffers) + :in-place t :key (lambda (buffer) (gethash buffer buffer-positions most-positive-fixnum)))))