all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#71960: [PATCH] Improve `tab-line-tabs-fixed-window-buffers` sorting performance
@ 2024-07-05 12:39 Eval Exec
  2024-07-06  6:30 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Eval Exec @ 2024-07-05 12:39 UTC (permalink / raw)
  To: 71960

[-- Attachment #1: Type: text/plain, Size: 966 bytes --]

Enhanced
`tab-line-tabs-fixed-window-buffers` performance by optimizing buffer
sorting mechanism. Replaced inefficient `seq-position` calls with a hash
table to cache buffer positions, significantly improving speed when
handling large buffer lists.



In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.42, cairo version 1.18.0)
Repository revision: 8198a144376cfea3490ea5628392fb3a49fec2d6
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12401000
System Description: NixOS 24.05 (Uakari)

Configured using:
 'configure
 --prefix=/nix/store/l5b0bbsxvyxd2ggi6j86inz2fwl9prkp-emacs-git-20240628.0
 --disable-build-details --with-modules --with-x-toolkit=gtk3
 --with-cairo --with-xft --with-compress-install
 --with-toolkit-scroll-bars --with-native-compilation
 --without-imagemagick --with-mailutils --without-small-ja-dic
 --with-tree-sitter --with-xinput2 --with-xwidgets --with-dbus
 --with-selinux'

[-- Attachment #2: 0001-Improve-tab-line-tabs-fixed-window-buffers-sorting-p.patch --]
[-- Type: text/x-patch, Size: 1772 bytes --]

From fa047a52c0d40aace236bd56f1d8ca70935f438a Mon Sep 17 00:00:00 2001
From: Eval EXEC <execvy@gmail.com>
Date: Fri, 5 Jul 2024 18:53:36 +0800
Subject: [PATCH] Improve `tab-line-tabs-fixed-window-buffers` sorting
 performance

* lsp/tab-line.el (tab-line-tabs-fixed-window-buffers): Enhanced
`tab-line-tabs-fixed-window-buffers` performance by optimizing buffer
sorting mechanism. Replaced inefficient `seq-position` calls with a hash
table to cache buffer positions, significantly improving speed when
handling large buffer lists.
---
 lisp/tab-line.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/tab-line.el b/lisp/tab-line.el
index 1d14fda9825..e4908c61542 100644
--- a/lisp/tab-line.el
+++ b/lisp/tab-line.el
@@ -555,10 +555,14 @@ 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)))
+                             (seq-do-indexed
+                              (lambda (buf idx) (puthash buf idx index-table))
+                              old-buffers)
+                             index-table))
          (new-buffers (sort (tab-line-tabs-window-buffers)
                             :key (lambda (buffer)
-                                   (or (seq-position old-buffers buffer)
-                                       most-positive-fixnum)))))
+                                   (gethash buffer buffer-positions most-positive-fixnum)))))
     (set-window-parameter nil 'tab-line-buffers new-buffers)
     new-buffers))
 
-- 
2.44.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#71960: [PATCH] Improve `tab-line-tabs-fixed-window-buffers` sorting performance
  2024-07-05 12:39 bug#71960: [PATCH] Improve `tab-line-tabs-fixed-window-buffers` sorting performance Eval Exec
@ 2024-07-06  6:30 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2024-07-06  6:30 UTC (permalink / raw)
  To: Eval Exec; +Cc: 71960

merge 71958 71961 71960
thanks

> From: Eval Exec <execvy@gmail.com>
> Date: Fri, 5 Jul 2024 20:39:39 +0800
> 
> Enhanced
> `tab-line-tabs-fixed-window-buffers` performance by optimizing buffer
> sorting mechanism. Replaced inefficient `seq-position` calls with a hash
> table to cache buffer positions, significantly improving speed when
> handling large buffer lists.

Actually, I see that all 4 bugs you submitted are the same bug, so I'm
merging them.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-06  6:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-05 12:39 bug#71960: [PATCH] Improve `tab-line-tabs-fixed-window-buffers` sorting performance Eval Exec
2024-07-06  6:30 ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.