GNU bug report logs -
#48264
28.0.50; Changing the default for DEFVAR_PER_BUFFER variables takes O(#buffers) time
Previous Next
Full log
View this message in rfc822 format
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Spencer Baugh <sbaugh <at> catern.com>
>> Date: Thu, 6 May 2021 17:33:39 -0400
>> Cc: Spencer Baugh <sbaugh <at> catern.com>
>>
>> --- a/src/buffer.c
>> +++ b/src/buffer.c
>> @@ -54,8 +54,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
>> defined with DEFVAR_PER_BUFFER, that have special slots in each buffer.
>> The default value occupies the same slot in this structure
>> as an individual buffer's value occupies in that buffer.
>> - Setting the default value also goes through the alist of buffers
>> - and stores into each buffer that does not say it has a local value. */
>> +*/
>
> This is a spurious change, please undo it.
>
>> @@ -1107,8 +1109,7 @@ BUFFER_CHECK_INDIRECTION (struct buffer *b)
>> that have special slots in each buffer.
>> The default value occupies the same slot in this structure
>> as an individual buffer's value occupies in that buffer.
>> - Setting the default value also goes through the alist of buffers
>> - and stores into each buffer that does not say it has a local value. */
>> +*/
>
> Likewise.
Not sure what you mean about this being a spurious change - the comment
is no longer accurate, setting the default value no longer does that as
of this commit.
>> +INLINE Lisp_Object
>> +bvar_get (struct buffer *b, ptrdiff_t offset)
> ^^^^^^^^
> How about calling this buffer_local_value instead? or maybe
> bvar_get_value?
Sure, any name works for me, although buffer_local_value already exists
(and does something different). I can call it bvar_get_value though.
>> @@ -1511,7 +1519,7 @@ KILL_PER_BUFFER_VALUE (struct buffer *b, int offset)
>> {
>> int idx = PER_BUFFER_IDX (offset);
>> SET_PER_BUFFER_VALUE_P (b, idx, 0);
>> - set_per_buffer_value (b, offset, per_buffer_default (offset));
>> + set_per_buffer_value (b, offset, Qunbound);
>> }
>
> Hmm... I'm probably missing something here: what about per-buffer
> variables that do have default values? how's that implemented in this
> new implementation?
If a variable that does have a default value, then setting the
per-buffer variable to Qunbound will cause BVAR_OR_DEFAULT and bvar_get
to return the default value.
If the variable doesn't have a default value, then it's permanently
buffer-local and it was always unsafe to call KILL_PER_BUFFER_VALUE on
it - but fortunately, we never do that.
This bug report was last modified 2 years and 289 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.