* 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'.
This commit is contained in:
Juri Linkov 2024-12-04 20:38:41 +02:00
parent d706be4b34
commit 25b4bf7fcd

View file

@ -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)))))