emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should `get-file-buffer' be implemented in Elisp?


From: Ihor Radchenko
Subject: Re: Should `get-file-buffer' be implemented in Elisp?
Date: Sun, 16 Jul 2023 20:19:10 +0000

Eli Zaretskii <eliz@gnu.org> writes:

>> I stay corrected.
>
> No need to stand corrected: the key is the interpretation of "as many
> as possible" -- it is not as simplistic as perhaps it could be.
>
> Basically, we have enough good reasons to rock the boat and make
> changes which could as side effects introduce bugs and subtle behavior
> change; let's not risk that when we don't have such a good reason.

Ok.

My original motivation about `get-file-buffer' was an observation that
searching alist might be sub-optimal.
I now have (length (buffer-list)) ;=> 578
and I though that it might be a good idea to keep track of
buffer name -> buffer associations in a hash table.
In particular, when using `get-buffer-create', and the buffer name does
not exist, Emacs has to scan all the buffer list, fail, and go ahead
creating the buffer. Hash table would help significantly in such
scenarios. And in general lookup as well as hash tables start to
outperform alists just at 20-30 elements [1]

But hacking C code and adding yet another internal variable looked like
not justified.

[1] 
https://flandrew.srht.site/listful/embracing-emacs-lisp-hash-tables-introducing-xht.html

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]