]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/tab-line.el (tab-line-tabs-fixed-window-buffers): More optimizations.
authorJuri Linkov <juri@linkov.net>
Wed, 4 Dec 2024 18:38:41 +0000 (20:38 +0200)
committerEshel Yaron <me@eshelyaron.com>
Fri, 6 Dec 2024 15:42:32 +0000 (16:42 +0100)
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

index f0a3fb9d89050442abe05200348774e54a41b256..43f26ba1d3649c973d86b3b4a84069bd865de8e3 100644 (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)))))