[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 00/16] Speeding up DEFVAR_PER_BUFFER
From: |
Spencer Baugh |
Subject: |
Re: [PATCH v2 00/16] Speeding up DEFVAR_PER_BUFFER |
Date: |
Tue, 01 Dec 2020 10:20:58 -0500 |
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Spencer Baugh <sbaugh@catern.com>
>> Cc: emacs-devel@gnu.org, arnold@tdrhq.com, monnier@iro.umontreal.ca,
>> dgutov@yandex.ru, rms@gnu.org
>> Date: Mon, 30 Nov 2020 15:11:31 -0500
>>
>> > But OTOH, referencing buffer-local values through BVAR is now slower,
>> > about twice slower, I guess? For example, the display code has 90
>> > uses of BVAR, and they will now be slower. I wonder what that means
>> > for us: we are making let-binding of local variables much faster, but
>> > "punish" the code that just accesses these variables in our inner
>> > loops.
>>
>> Yes, it's probably a trade-off.
>
> In fact, the current code is slow only when the buffer that's current
> at the moment of the let-binding doesn't have a buffer-local value for
> the variable. Because if the current buffer does have a local value,
> the let-binding simply changes that single local value.
Just for the sake of completeness, note that set-default is also slow -
it's changing the default that's slow, which is done by both let-binding
without a buffer-local and set-default.
Lisp code is much less likely to call set-default in a tight loop, of
course. Speculating wildly, maybe that's why this implementation was
chosen in the first place - the idea that it's fine for it to be slow to
change the default, since that should be a rare operation...