[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#48264: [PATCH v4 06/14] Rearrange set_internal for buffer forwarded
From: |
Spencer Baugh |
Subject: |
bug#48264: [PATCH v4 06/14] Rearrange set_internal for buffer forwarded symbols |
Date: |
Fri, 7 May 2021 22:08:57 -0400 |
Previously, when setting buffer-local values for DEFVAR_PER_BUFFER
variables, the call to SET_PER_BUFFER_VALUE_P was far from the call to
set_per_buffer_value, even though they're conceptually tied together.
Now, the two calls are in the same place in store_symval_forwarding,
and we can delete the old call to SET_PER_BUFFER_VALUE_P in
set_internal.
Since we did this, we need to also avoid calling
store_symval_forwarding in set_internal when setting the default value
for a DEFVAR_PER_BUFFER variable.
This improves clarity quite a bit; it also makes it easier to later
merge set_per_buffer_value and SET_PER_BUFFER_VALUE_P together.
* src/data.c (store_symval_forwarding): Call SET_PER_BUFFER_VALUE_P
directly for buffer-forwarded symbols.
(set_internal): Don't call SET_PER_BUFFER_VALUE_P for buffer-forwarded
symbols. Also don't call store_symval_forwarding when we're setting
the default value for a buffer-forwarded symbol.
---
src/data.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/data.c b/src/data.c
index ec9fc57048..9d8b722a41 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1320,6 +1320,9 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object
newval,
if (buf == NULL)
buf = current_buffer;
set_per_buffer_value (buf, offset, newval);
+ int idx = PER_BUFFER_IDX (offset);
+ if (idx > 0)
+ SET_PER_BUFFER_VALUE_P (buf, idx, 1);
}
break;
@@ -1593,17 +1596,16 @@ set_internal (Lisp_Object symbol, Lisp_Object newval,
Lisp_Object where,
struct buffer *buf
= BUFFERP (where) ? XBUFFER (where) : current_buffer;
lispfwd innercontents = SYMBOL_FWD (sym);
+ bool should_store = true;
if (BUFFER_OBJFWDP (innercontents))
{
int offset = XBUFFER_OBJFWD (innercontents)->offset;
- int idx = PER_BUFFER_IDX (offset);
if (bindflag == SET_INTERNAL_SET
- && !PER_BUFFER_VALUE_P (buf, offset))
+ && !PER_BUFFER_VALUE_P (buf, offset)
+ && let_shadows_buffer_binding_p (sym))
{
- if (let_shadows_buffer_binding_p (sym))
- set_default_internal (symbol, newval, bindflag);
- else
- SET_PER_BUFFER_VALUE_P (buf, idx, 1);
+ set_default_internal (symbol, newval, bindflag);
+ should_store = false;
}
}
@@ -1613,7 +1615,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval,
Lisp_Object where,
sym->u.s.redirect = SYMBOL_PLAINVAL;
SET_SYMBOL_VAL (sym, newval);
}
- else
+ else if (should_store)
store_symval_forwarding (/* sym, */ innercontents, newval, buf);
break;
}
--
2.31.1
- bug#48264: 28.0.50; Changing the default for DEFVAR_PER_BUFFER variables takes O(#buffers) time, Spencer Baugh, 2021/05/06
- bug#48264: [PATCH v3 01/15] Stop checking the constant default for enable_multibyte_characters, Spencer Baugh, 2021/05/06
- bug#48264: [PATCH v3 00/15] Speeding up setting the default for DEFVAR_PER_BUFFER vars, Spencer Baugh, 2021/05/06
- bug#48264: [PATCH v3 00/15] Speeding up setting the default for DEFVAR_PER_BUFFER vars, Eli Zaretskii, 2021/05/07
- bug#48264: [PATCH v4 00/15] Speeding up setting the default for DEFVAR_PER_BUFFER vars, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 00/15] Speeding up setting the default for DEFVAR_PER_BUFFER vars, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 06/14] Rearrange set_internal for buffer forwarded symbols,
Spencer Baugh <=
- bug#48264: [PATCH v4 11/14] Set buffer_defaults fields without a default to Qunbound, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 13/14] Remove PER_BUFFER_IDX and buffer_local_flags, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 14/14] Add and use BVAR_FIELD macros, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 05/14] Add and use KILL_PER_BUFFER_VALUE, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 03/14] Add and use BVAR_HAS_DEFAULT_VALUE_P, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 01/14] Stop checking the constant default for enable_multibyte_characters, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 02/14] Take offset not idx in PER_BUFFER_VALUE_P, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 04/14] Combine unnecessarily separate loops in buffer.c, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 07/14] Use BVAR_OR_DEFAULT for per-buffer vars with defaults, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 10/14] Delete SET_PER_BUFFER_VALUE_P and buffer local_flags field, Spencer Baugh, 2021/05/07