GNU bug report logs -
#48264
28.0.50; Changing the default for DEFVAR_PER_BUFFER variables takes O(#buffers) time
Previous Next
Full log
Message #161 received at 48264 <at> debbugs.gnu.org (full text, mbox):
This makes the code more clear and allows us to more easily change how
this property is determined.
* src/buffer.h (BVAR_HAS_DEFAULT_VALUE_P): New function.
* src/buffer.c (reset_buffer_local_variables):
* src/data.c (set_default_internal, Fkill_local_variable): Use
BVAR_HAS_DEFAULT_VALUE_P.
---
src/buffer.c | 2 +-
src/buffer.h | 10 ++++++++++
src/data.c | 5 ++---
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/buffer.c b/src/buffer.c
index c395c6ec98..efc85bf378 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1108,7 +1108,7 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too)
FOR_EACH_PER_BUFFER_OBJECT_AT (offset)
{
int idx = PER_BUFFER_IDX (offset);
- if ((idx > 0
+ if ((BVAR_HAS_DEFAULT_VALUE_P (offset)
&& (permanent_too
|| buffer_permanent_local_flags[idx] == 0)))
set_per_buffer_value (b, offset, per_buffer_default (offset));
diff --git a/src/buffer.h b/src/buffer.h
index 7367c2cb2b..13fda0c702 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1481,6 +1481,16 @@ set_per_buffer_value (struct buffer *b, int offset, Lisp_Object value)
*(Lisp_Object *)(offset + (char *) b) = value;
}
+/* Value is true if the variable with offset OFFSET has a default
+ value; false if the variable has no default, and is therefore
+ always local. */
+
+INLINE bool
+BVAR_HAS_DEFAULT_VALUE_P (int offset)
+{
+ return PER_BUFFER_IDX (offset) > 0;
+}
+
/* Value is true if the variable with offset OFFSET has a local value
in buffer B. */
diff --git a/src/data.c b/src/data.c
index bd399e0439..891a81b7f3 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1879,13 +1879,12 @@ set_default_internal (Lisp_Object symbol, Lisp_Object value,
if (BUFFER_OBJFWDP (valcontents))
{
int offset = XBUFFER_OBJFWD (valcontents)->offset;
- int idx = PER_BUFFER_IDX (offset);
set_per_buffer_default (offset, value);
/* If this variable is not always local in all buffers,
set it in the buffers that don't nominally have a local value. */
- if (idx > 0)
+ if (BVAR_HAS_DEFAULT_VALUE_P (offset))
{
Lisp_Object buf, tail;
@@ -2157,7 +2156,7 @@ From now on the default value will apply in this buffer. Return VARIABLE. */)
int offset = XBUFFER_OBJFWD (valcontents)->offset;
int idx = PER_BUFFER_IDX (offset);
- if (idx > 0)
+ if (BVAR_HAS_DEFAULT_VALUE_P (offset))
{
SET_PER_BUFFER_VALUE_P (current_buffer, idx, 0);
set_per_buffer_value (current_buffer, offset,
--
2.31.1
This bug report was last modified 2 years and 290 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.