emacs-devel
[Top][All Lists]
Advanced

[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




reply via email to

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