[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 12/16] Rearrange set_internal for buffer forwarded symbols
From: |
Spencer Baugh |
Subject: |
[PATCH v2 12/16] Rearrange set_internal for buffer forwarded symbols |
Date: |
Sat, 21 Nov 2020 21:34:41 -0500 |
Previously, we unnecessarily called store_symval_forwarding even after
calling set_default_internal. store_symval_forwarding would have no
additional effect after a call to set_default_internal.
Now, we don't call store_symval_forwarding if we've called
set_default_internal. As a consequence, we can also move the call to
SET_PER_BUFFER_VALUE_P into store_symval_forwarding, where it's closer
to the per-buffer-value actually being set, which improves clarity.
We'll later move the effect of SET_PER_BUFFER_VALUE_P into
set_per_buffer_value, so they need to be together.
Still, this change is a little ugly, there's maybe some other way to
do it that is a little more clear...
---
src/data.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/data.c b/src/data.c
index f472127599..53b08a1aa4 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1163,6 +1163,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;
@@ -1436,17 +1439,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;
}
}
@@ -1456,7 +1458,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.28.0
- [PATCH v2 04/16] Take buffer field name in DEFVAR_PER_BUFFER, (continued)
- [PATCH v2 04/16] Take buffer field name in DEFVAR_PER_BUFFER, Spencer Baugh, 2020/11/21
- [PATCH v2 08/16] Combine unnecessarily separate loops in buffer.c, Spencer Baugh, 2020/11/21
- [PATCH v2 09/16] Add and use BUFFER_DEFAULT_VALUE_P, Spencer Baugh, 2020/11/21
- [PATCH v2 06/16] Use bset_* functions instead of BVAR, Spencer Baugh, 2020/11/21
- [PATCH v2 07/16] Take offset not idx in PER_BUFFER_VALUE_P, Spencer Baugh, 2020/11/21
- [PATCH v2 11/16] Assert that PER_BUFFER_IDX for Lisp variables is not 0, Spencer Baugh, 2020/11/21
- [PATCH v2 14/16] Remove unnecessary Qunbound check, Spencer Baugh, 2020/11/21
- [PATCH v2 10/16] Add and use KILL_PER_BUFFER_VALUE, Spencer Baugh, 2020/11/21
- [PATCH v2 13/16] Get rid of buffer_permanent_local_flags array, Spencer Baugh, 2020/11/21
- Re: [PATCH v2 13/16] Get rid of buffer_permanent_local_flags array, Eli Zaretskii, 2020/11/22
- [PATCH v2 12/16] Rearrange set_internal for buffer forwarded symbols,
Spencer Baugh <=
- [PATCH v2 15/16] Remove local_flags array in struct buffer, Spencer Baugh, 2020/11/21
- Re: [PATCH v2 15/16] Remove local_flags array in struct buffer, Stefan Monnier, 2020/11/22
- [PATCH v2 16/16] Remove usage of buffer_local_flags, Spencer Baugh, 2020/11/21
- Re: [PATCH v2 00/16] Speeding up DEFVAR_PER_BUFFER, Kévin Le Gouguec, 2020/11/22
- Re: [PATCH v2 00/16] Speeding up DEFVAR_PER_BUFFER, Eli Zaretskii, 2020/11/22
- Re: [PATCH v2 00/16] Speeding up DEFVAR_PER_BUFFER, Spencer Baugh, 2020/11/22
- Re: [PATCH v2 00/16] Speeding up DEFVAR_PER_BUFFER, Eli Zaretskii, 2020/11/22
- Re: [PATCH v2 00/16] Speeding up DEFVAR_PER_BUFFER, Spencer Baugh, 2020/11/29
- Re: [PATCH v2 00/16] Speeding up DEFVAR_PER_BUFFER, Eli Zaretskii, 2020/11/30
- Re: [PATCH v2 00/16] Speeding up DEFVAR_PER_BUFFER, Spencer Baugh, 2020/11/30