From: Spencer Baugh <sbaugh@catern.com>
To: emacs-devel@gnu.org
Cc: Spencer Baugh <sbaugh@catern.com>,
Arnold Noronha <arnold@tdrhq.com>,
Stefan Monnier <monnier@iro.umontreal.ca>,
Dmitry Gutov <dgutov@yandex.ru>
Subject: [PATCH v2 13/16] Get rid of buffer_permanent_local_flags array
Date: Sat, 21 Nov 2020 21:34:42 -0500 [thread overview]
Message-ID: <2951231979c58366ff6ce1f4f220bedd2d221e13.1606009917.git.sbaugh@catern.com> (raw)
In-Reply-To: <cover.1606009917.git.sbaugh@catern.com>
This is only used in one place, for two variables; we can just special
case those variables in the place it's used.
---
lisp/bindings.el | 3 ++-
src/buffer.c | 28 +++++++++-------------------
2 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 250234e94c..ffa1c94584 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -771,7 +771,8 @@ okay. See `mode-line-format'.")
;; `kill-all-local-variables', because they have no default value.
;; For consistency, we give them the `permanent-local' property, even
;; though `kill-all-local-variables' does not actually consult it.
-;; See init_buffer_once in buffer.c for the origins of this list.
+;; See init_buffer_once and reset_buffer_local_variables in buffer.c
+;; for the origins of this list.
(mapc (lambda (sym) (put sym 'permanent-local t))
'(buffer-file-name default-directory buffer-backed-up
diff --git a/src/buffer.c b/src/buffer.c
index b05fdbd9b2..e7f9573eb5 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -94,10 +94,6 @@ struct buffer buffer_local_symbols;
((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, \
min (PTRDIFF_MAX, SIZE_MAX) / word_size))
-/* Flags indicating which built-in buffer-local variables
- are permanent locals. */
-static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS];
-
/* Number of per-buffer variables used. */
static int last_per_buffer_idx;
@@ -1081,10 +1077,14 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too)
/* For each slot that has a default value, copy that into the slot. */
FOR_EACH_PER_BUFFER_OBJECT_AT (offset)
{
- int idx = PER_BUFFER_IDX (offset);
if ((BUFFER_DEFAULT_VALUE_P (offset)
- && (permanent_too
- || buffer_permanent_local_flags[idx] == 0)))
+ && (permanent_too
+ /* Special case these two for backwards-compat; they're
+ flagged as permanent-locals in bindings.el, even
+ though they do have default values. */
+ || (offset != PER_BUFFER_VAR_OFFSET (truncate_lines)
+ && offset !=
+ PER_BUFFER_VAR_OFFSET (buffer_file_coding_system)))))
KILL_PER_BUFFER_VALUE (b, offset);
}
}
@@ -5119,7 +5119,6 @@ init_buffer_once (void)
buffer_defaults: default values of buffer-locals
buffer_local_flags: metadata
- buffer_permanent_local_flags: metadata
buffer_local_symbols: metadata
There must be a simpler way to store the metadata.
@@ -5127,11 +5126,6 @@ init_buffer_once (void)
int idx;
- /* Items flagged permanent get an explicit permanent-local property
- added in bindings.el, for clarity. */
- PDUMPER_REMEMBER_SCALAR (buffer_permanent_local_flags);
- memset (buffer_permanent_local_flags, 0, sizeof buffer_permanent_local_flags);
-
/* 0 means not a lisp var, -1 means always local, else mask. */
memset (&buffer_local_flags, 0, sizeof buffer_local_flags);
bset_filename (&buffer_local_flags, make_fixnum (-1));
@@ -5178,9 +5172,7 @@ init_buffer_once (void)
XSETFASTINT (BVAR (&buffer_local_flags, selective_display), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, selective_display_ellipses), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, tab_width), idx); ++idx;
- XSETFASTINT (BVAR (&buffer_local_flags, truncate_lines), idx);
- /* Make this one a permanent local. */
- buffer_permanent_local_flags[idx++] = 1;
+ XSETFASTINT (BVAR (&buffer_local_flags, truncate_lines), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, word_wrap), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, ctl_arrow), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, fill_column), idx); ++idx;
@@ -5194,9 +5186,7 @@ init_buffer_once (void)
XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_direction), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_separate_re), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_start_re), idx); ++idx;
- XSETFASTINT (BVAR (&buffer_local_flags, buffer_file_coding_system), idx);
- /* Make this one a permanent local. */
- buffer_permanent_local_flags[idx++] = 1;
+ XSETFASTINT (BVAR (&buffer_local_flags, buffer_file_coding_system), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, left_margin_cols), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, right_margin_cols), idx); ++idx;
XSETFASTINT (BVAR (&buffer_local_flags, left_fringe_width), idx); ++idx;
--
2.28.0
next prev parent reply other threads:[~2020-11-22 2:34 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-14 16:34 ido-switch-buffer is slow with many buffers; others are fast catern
2020-11-14 18:22 ` Stefan Monnier
2020-11-14 20:06 ` sbaugh
2020-11-14 23:00 ` Stefan Monnier
2020-11-14 23:16 ` Dmitry Gutov
2020-11-15 0:19 ` Spencer Baugh
2020-11-15 15:15 ` Stefan Monnier
2020-11-15 20:49 ` Spencer Baugh
2020-11-15 23:58 ` Arnold Noronha
2020-11-19 15:38 ` [PATCH 00/10] Speeding up DEFVAR_PER_BUFFER (Was: ido-switch-buffer is slow) Spencer Baugh
2020-11-19 17:29 ` [PATCH 00/10] Speeding up DEFVAR_PER_BUFFER Stefan Monnier
2020-11-22 2:34 ` [PATCH v2 00/16] " Spencer Baugh
2020-11-22 2:34 ` [PATCH v2 01/16] Add a test for let-binding unwinding Spencer Baugh
2020-11-25 20:53 ` Stefan Monnier
2020-11-30 17:31 ` Spencer Baugh
2020-12-01 16:44 ` Eli Zaretskii
2020-11-22 2:34 ` [PATCH v2 02/16] Assert not local-variable-p after setq in let_default binding Spencer Baugh
2020-11-25 20:54 ` Stefan Monnier
2020-12-01 16:45 ` Eli Zaretskii
2020-11-22 2:34 ` [PATCH v2 03/16] Stop checking the constant default for enable_multibyte_characters Spencer Baugh
2020-11-25 20:57 ` Stefan Monnier
2020-12-01 16:52 ` Eli Zaretskii
2020-11-22 2:34 ` [PATCH v2 04/16] Take buffer field name in DEFVAR_PER_BUFFER Spencer Baugh
2020-12-01 16:56 ` Eli Zaretskii
2020-11-22 2:34 ` [PATCH v2 05/16] Add BVAR_DEFAULT for access to buffer defaults Spencer Baugh
2020-12-01 17:00 ` Eli Zaretskii
2020-11-22 2:34 ` [PATCH v2 06/16] Use bset_* functions instead of BVAR Spencer Baugh
2020-12-01 17:12 ` Eli Zaretskii
2020-11-22 2:34 ` [PATCH v2 07/16] Take offset not idx in PER_BUFFER_VALUE_P Spencer Baugh
2020-12-01 17:20 ` Eli Zaretskii
2020-11-22 2:34 ` [PATCH v2 08/16] Combine unnecessarily separate loops in buffer.c Spencer Baugh
2020-12-01 17:22 ` Eli Zaretskii
2020-11-22 2:34 ` [PATCH v2 09/16] Add and use BUFFER_DEFAULT_VALUE_P Spencer Baugh
2020-12-01 17:24 ` Eli Zaretskii
2020-11-22 2:34 ` [PATCH v2 10/16] Add and use KILL_PER_BUFFER_VALUE Spencer Baugh
2020-12-01 17:26 ` Eli Zaretskii
2020-11-22 2:34 ` [PATCH v2 11/16] Assert that PER_BUFFER_IDX for Lisp variables is not 0 Spencer Baugh
2020-12-01 17:32 ` Eli Zaretskii
2020-11-22 2:34 ` [PATCH v2 12/16] Rearrange set_internal for buffer forwarded symbols Spencer Baugh
2020-12-01 17:35 ` Eli Zaretskii
2020-11-22 2:34 ` Spencer Baugh [this message]
2020-11-22 16:16 ` [PATCH v2 13/16] Get rid of buffer_permanent_local_flags array Eli Zaretskii
2020-12-01 17:39 ` Eli Zaretskii
2020-11-22 2:34 ` [PATCH v2 14/16] Remove unnecessary Qunbound check Spencer Baugh
2020-12-01 17:40 ` Eli Zaretskii
2020-11-22 2:34 ` [PATCH v2 15/16] Remove local_flags array in struct buffer Spencer Baugh
2020-11-22 20:04 ` Stefan Monnier
2020-12-01 17:57 ` Eli Zaretskii
2020-11-22 2:34 ` [PATCH v2 16/16] Remove usage of buffer_local_flags Spencer Baugh
2020-12-01 18:05 ` Eli Zaretskii
2020-11-22 11:19 ` [PATCH v2 00/16] Speeding up DEFVAR_PER_BUFFER Kévin Le Gouguec
2020-11-22 16:12 ` Eli Zaretskii
2020-11-22 16:28 ` Spencer Baugh
2020-11-22 17:13 ` Eli Zaretskii
2020-11-29 17:41 ` Spencer Baugh
2020-11-30 18:32 ` Eli Zaretskii
2020-11-30 20:11 ` Spencer Baugh
2020-11-30 22:10 ` Stefan Monnier
2020-11-30 22:26 ` Andrea Corallo via Emacs development discussions.
2020-12-01 15:15 ` Eli Zaretskii
2020-12-01 15:56 ` Stefan Monnier
2020-12-01 15:10 ` Eli Zaretskii
2020-12-01 15:20 ` Spencer Baugh
2020-12-01 16:01 ` Stefan Monnier
2020-12-01 16:16 ` Eli Zaretskii
2020-12-01 18:10 ` Eli Zaretskii
2020-11-22 20:11 ` Stefan Monnier
2020-11-19 15:38 ` [PATCH 01/10] Take buffer field name in DEFVAR_PER_BUFFER Spencer Baugh
2020-11-19 15:38 ` [PATCH 02/10] Add bset_save_length and use it Spencer Baugh
2020-11-19 15:38 ` [PATCH 03/10] Use bset_last_selected_window everywhere Spencer Baugh
2020-11-19 15:38 ` [PATCH 04/10] Use bset_enable_multibyte_characters everywhere Spencer Baugh
2020-11-19 15:38 ` [PATCH 05/10] Add BVAR_DEFAULT for access to buffer defaults Spencer Baugh
2020-11-19 15:38 ` [PATCH 06/10] Disallow using BVAR as an lvalue Spencer Baugh
2020-11-19 15:38 ` [PATCH 07/10] Reorder buffer.h for upcoming rework of BVAR Spencer Baugh
2020-11-19 15:38 ` [PATCH 08/10] Make cache_long_scans buffer-local when setting it Spencer Baugh
2020-11-19 15:38 ` [PATCH 09/10] Access buffer_defaults in BVAR if there's no local binding Spencer Baugh
2020-11-19 18:08 ` Stefan Monnier
2020-11-19 18:21 ` Eli Zaretskii
2020-11-19 15:38 ` [PATCH 10/10] Don't iterate over all buffers in set_default_internal Spencer Baugh
2020-11-19 18:21 ` Stefan Monnier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2951231979c58366ff6ce1f4f220bedd2d221e13.1606009917.git.sbaugh@catern.com \
--to=sbaugh@catern.com \
--cc=arnold@tdrhq.com \
--cc=dgutov@yandex.ru \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.