GNU bug report logs - #48264
28.0.50; Changing the default for DEFVAR_PER_BUFFER variables takes O(#buffers) time

Previous Next

Package: emacs;

Reported by: Spencer Baugh <sbaugh <at> catern.com>

Date: Thu, 6 May 2021 20:25:01 UTC

Severity: normal

Found in version 28.0.50

Full log


Message #167 received at 48264 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> catern.com>
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh <at> catern.com>
Subject: [PATCH v4 05/14] Add and use KILL_PER_BUFFER_VALUE
Date: Fri,  7 May 2021 22:08:56 -0400
This makes the code more clear and allows us to more easily change how
this function is implemented.

* src/buffer.h (KILL_PER_BUFFER_VALUE): New function.
* src/buffer.c (reset_buffer_local_variables):
* src/data.c (Fkill_local_variable): Use KILL_PER_BUFFER_VALUE.
---
 src/buffer.c |  5 +----
 src/buffer.h | 10 ++++++++++
 src/data.c   |  8 +-------
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index 4336e10a27..2ecbaa91cc 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1107,10 +1107,7 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too)
       if ((BVAR_HAS_DEFAULT_VALUE_P (offset)
 	   && (permanent_too
 	       || buffer_permanent_local_flags[idx] == 0)))
-        {
-	  SET_PER_BUFFER_VALUE_P (b, idx, 0);
-	  set_per_buffer_value (b, offset, per_buffer_default (offset));
-        }
+        KILL_PER_BUFFER_VALUE (b, offset);
     }
 }
 
diff --git a/src/buffer.h b/src/buffer.h
index 13fda0c702..31ab4fb3dd 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1502,6 +1502,16 @@ PER_BUFFER_VALUE_P (struct buffer *b, int offset)
   return idx == -1 || b->local_flags[idx];
 }
 
+/* Kill the per-buffer binding for this value, if there is one. */
+
+INLINE void
+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));
+}
+
 /* Downcase a character C, or make no change if that cannot be done.  */
 INLINE int
 downcase (int c)
diff --git a/src/data.c b/src/data.c
index 891a81b7f3..ec9fc57048 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2154,14 +2154,8 @@ From now on the default value will apply in this buffer.  Return VARIABLE.  */)
 	if (BUFFER_OBJFWDP (valcontents))
 	  {
 	    int offset = XBUFFER_OBJFWD (valcontents)->offset;
-	    int idx = PER_BUFFER_IDX (offset);
-
 	    if (BVAR_HAS_DEFAULT_VALUE_P (offset))
-	      {
-		SET_PER_BUFFER_VALUE_P (current_buffer, idx, 0);
-		set_per_buffer_value (current_buffer, offset,
-				      per_buffer_default (offset));
-	      }
+	      KILL_PER_BUFFER_VALUE (current_buffer, offset);
 	  }
 	return variable;
       }
-- 
2.31.1





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.