From: Sergey Vinokurov <serg.foo@gmail.com>
To: 53242@debbugs.gnu.org
Subject: bug#53242: [PATCH] unify reads from local_var_alist
Date: Fri, 14 Jan 2022 00:23:42 +0000 [thread overview]
Message-ID: <50d65dbc-f3d6-86fb-6a7c-9200a6525ec2@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 403 bytes --]
Hello,
I've noticed that local_var_alist field of the buffer structure is
accessed inconsistently. Sometimes it's Fassoc, sometimes it's Fassq and
other times it's assq_no_quit and even an explicit loop.
I think it's safe to unify all the accesses via assq_no_quit since it's
an internaly maintained alist that definitely has no cycles and elements
are cons cells with symbol as their car.
Sergey
[-- Attachment #2: 0001-Unify-getting-of-values-from-local_var_alist.patch --]
[-- Type: text/x-patch, Size: 2767 bytes --]
From 2ed2cbb91d5e09615ad6610810014198a269d539 Mon Sep 17 00:00:00 2001
From: Sergey Vinokurov <serg.foo@gmail.com>
Date: Fri, 14 Jan 2022 00:16:19 +0000
Subject: [PATCH] Unify getting of values from local_var_alist
---
src/buffer.c | 2 +-
src/data.c | 16 ++++++----------
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/src/buffer.c b/src/buffer.c
index 10ac91915c..a3091015d9 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1247,7 +1247,7 @@ buffer_local_value (Lisp_Object variable, Lisp_Object buffer)
{ /* Look in local_var_alist. */
struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym);
XSETSYMBOL (variable, sym); /* Update In case of aliasing. */
- result = Fassoc (variable, BVAR (buf, local_var_alist), Qnil);
+ result = assq_no_quit (variable, BVAR (buf, local_var_alist));
if (!NILP (result))
{
if (blv->fwd.fwdptr)
diff --git a/src/data.c b/src/data.c
index 5d0790692b..f287c38fcd 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2103,7 +2103,7 @@ DEFUN ("make-local-variable", Fmake_local_variable, Smake_local_variable,
/* Make sure this buffer has its own value of symbol. */
XSETSYMBOL (variable, sym); /* Update in case of aliasing. */
- tem = Fassq (variable, BVAR (current_buffer, local_var_alist));
+ tem = assq_no_quit (variable, BVAR (current_buffer, local_var_alist));
if (NILP (tem))
{
if (let_shadows_buffer_binding_p (sym))
@@ -2183,7 +2183,7 @@ DEFUN ("kill-local-variable", Fkill_local_variable, Skill_local_variable,
/* Get rid of this buffer's alist element, if any. */
XSETSYMBOL (variable, sym); /* Propagate variable indirection. */
- tem = Fassq (variable, BVAR (current_buffer, local_var_alist));
+ tem = assq_no_quit (variable, BVAR (current_buffer, local_var_alist));
if (!NILP (tem))
bset_local_var_alist
(current_buffer,
@@ -2224,7 +2224,7 @@ DEFUN ("local-variable-p", Flocal_variable_p, Slocal_variable_p,
case SYMBOL_PLAINVAL: return Qnil;
case SYMBOL_LOCALIZED:
{
- Lisp_Object tail, elt, tmp;
+ Lisp_Object tmp;
struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym);
XSETBUFFER (tmp, buf);
XSETSYMBOL (variable, sym); /* Update in case of aliasing. */
@@ -2232,13 +2232,9 @@ DEFUN ("local-variable-p", Flocal_variable_p, Slocal_variable_p,
if (EQ (blv->where, tmp)) /* The binding is already loaded. */
return blv_found (blv) ? Qt : Qnil;
else
- for (tail = BVAR (buf, local_var_alist); CONSP (tail); tail = XCDR (tail))
- {
- elt = XCAR (tail);
- if (EQ (variable, XCAR (elt)))
- return Qt;
- }
- return Qnil;
+ return NILP (assq_no_quit (variable, BVAR (buf, local_var_alist)))
+ ? Qnil
+ : Qt;
}
case SYMBOL_FORWARDED:
{
--
2.34.1
next reply other threads:[~2022-01-14 0:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-14 0:23 Sergey Vinokurov [this message]
2022-01-14 7:49 ` bug#53242: [PATCH] unify reads from local_var_alist Lars Ingebrigtsen
2022-01-14 8:08 ` Eli Zaretskii
2022-01-14 8:33 ` Lars Ingebrigtsen
2022-01-14 18:37 ` Sergey Vinokurov
2022-01-14 19:01 ` Eli Zaretskii
2022-01-14 21:01 ` Sergey Vinokurov
2022-01-15 7:32 ` Eli Zaretskii
2022-01-15 11:41 ` Sergey Vinokurov
2022-01-15 16:02 ` Corwin Brust
2022-01-15 17:54 ` Sergey Vinokurov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50d65dbc-f3d6-86fb-6a7c-9200a6525ec2@gmail.com \
--to=serg.foo@gmail.com \
--cc=53242@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).