From 4ec51cba6ef264f0567096b4f7596fbb71a304d2 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 4 Dec 2024 20:38:41 +0200 Subject: [PATCH] * 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) --- lisp/tab-line.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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))))) -- 2.39.5