aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorIhor Radchenko2023-12-15 11:47:45 +0100
committerEli Zaretskii2023-12-30 10:03:46 +0200
commitaa0037aaf7c2cd7052925fdeca73c77c91254de1 (patch)
tree0d97c7c0d6d31149404f9d3e687bd1de4abfeb81 /src/buffer.c
parent784acce8425fb3143719d34be1e39be499564dfb (diff)
downloademacs-aa0037aaf7c2cd7052925fdeca73c77c91254de1.tar.gz
emacs-aa0037aaf7c2cd7052925fdeca73c77c91254de1.zip
Improve performance let-binding `case-fold-search' (bug#66117)
* src/buffer.h: Remove case_fold_search_ buffer object slot. * src/buffer.c (bset_case_fold_search): Remove - no longer needed. (init_buffer_once): Remove removed buffer slot init. (syms_of_buffer): Use DEFVAR_LISP to define `case-fold-search' and declare it buffer-local. * src/minibuf.c (syms_of_minibuf): Remove DEFSYM call for `case-fold-search' symbol. It now lives in `syms_of_buffer'. * src/editfns.c (Fcompare_buffer_substrings): (Fchar_equal): * src/search.c (looking_at_1): (string_match_1): (search_command): (Fre__describe_compiled): Adjust C queries to `case-fold-search' value to use C globals instead of BVAR macro. * doc/lispref/internals.texi (Buffer Internals): Do not list `case_fold_search' slot. See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=66117#259 When used as buffer slot, let-binding `case-fold-search' would scale with the number of live buffers and can be slow. This change makes let-binding much faster at the cost of slightly slower `set-buffer'.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/buffer.c b/src/buffer.c
index d08ea44d797..637830704e6 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -210,11 +210,6 @@ bset_buffer_file_coding_system (struct buffer *b, Lisp_Object val)
210 b->buffer_file_coding_system_ = val; 210 b->buffer_file_coding_system_ = val;
211} 211}
212static void 212static void
213bset_case_fold_search (struct buffer *b, Lisp_Object val)
214{
215 b->case_fold_search_ = val;
216}
217static void
218bset_ctl_arrow (struct buffer *b, Lisp_Object val) 213bset_ctl_arrow (struct buffer *b, Lisp_Object val)
219{ 214{
220 b->ctl_arrow_ = val; 215 b->ctl_arrow_ = val;
@@ -4692,7 +4687,6 @@ init_buffer_once (void)
4692 XSETFASTINT (BVAR (&buffer_local_flags, mode_line_format), idx); ++idx; 4687 XSETFASTINT (BVAR (&buffer_local_flags, mode_line_format), idx); ++idx;
4693 XSETFASTINT (BVAR (&buffer_local_flags, abbrev_mode), idx); ++idx; 4688 XSETFASTINT (BVAR (&buffer_local_flags, abbrev_mode), idx); ++idx;
4694 XSETFASTINT (BVAR (&buffer_local_flags, overwrite_mode), idx); ++idx; 4689 XSETFASTINT (BVAR (&buffer_local_flags, overwrite_mode), idx); ++idx;
4695 XSETFASTINT (BVAR (&buffer_local_flags, case_fold_search), idx); ++idx;
4696 XSETFASTINT (BVAR (&buffer_local_flags, auto_fill_function), idx); ++idx; 4690 XSETFASTINT (BVAR (&buffer_local_flags, auto_fill_function), idx); ++idx;
4697 XSETFASTINT (BVAR (&buffer_local_flags, selective_display), idx); ++idx; 4691 XSETFASTINT (BVAR (&buffer_local_flags, selective_display), idx); ++idx;
4698 XSETFASTINT (BVAR (&buffer_local_flags, selective_display_ellipses), idx); ++idx; 4692 XSETFASTINT (BVAR (&buffer_local_flags, selective_display_ellipses), idx); ++idx;
@@ -4785,7 +4779,6 @@ init_buffer_once (void)
4785 bset_tab_line_format (&buffer_defaults, Qnil); 4779 bset_tab_line_format (&buffer_defaults, Qnil);
4786 bset_abbrev_mode (&buffer_defaults, Qnil); 4780 bset_abbrev_mode (&buffer_defaults, Qnil);
4787 bset_overwrite_mode (&buffer_defaults, Qnil); 4781 bset_overwrite_mode (&buffer_defaults, Qnil);
4788 bset_case_fold_search (&buffer_defaults, Qt);
4789 bset_auto_fill_function (&buffer_defaults, Qnil); 4782 bset_auto_fill_function (&buffer_defaults, Qnil);
4790 bset_selective_display (&buffer_defaults, Qnil); 4783 bset_selective_display (&buffer_defaults, Qnil);
4791 bset_selective_display_ellipses (&buffer_defaults, Qt); 4784 bset_selective_display_ellipses (&buffer_defaults, Qt);
@@ -5215,10 +5208,6 @@ Format with `format-mode-line' to produce a string value. */);
5215 doc: /* Non-nil if Abbrev mode is enabled. 5208 doc: /* Non-nil if Abbrev mode is enabled.
5216Use the command `abbrev-mode' to change this variable. */); 5209Use the command `abbrev-mode' to change this variable. */);
5217 5210
5218 DEFVAR_PER_BUFFER ("case-fold-search", &BVAR (current_buffer, case_fold_search),
5219 Qnil,
5220 doc: /* Non-nil if searches and matches should ignore case. */);
5221
5222 DEFVAR_PER_BUFFER ("fill-column", &BVAR (current_buffer, fill_column), 5211 DEFVAR_PER_BUFFER ("fill-column", &BVAR (current_buffer, fill_column),
5223 Qintegerp, 5212 Qintegerp,
5224 doc: /* Column beyond which automatic line-wrapping should happen. 5213 doc: /* Column beyond which automatic line-wrapping should happen.
@@ -5951,6 +5940,12 @@ If `delete-auto-save-files' is nil, any autosave deletion is inhibited. */);
5951This is the default. If nil, auto-save file deletion is inhibited. */); 5940This is the default. If nil, auto-save file deletion is inhibited. */);
5952 delete_auto_save_files = 1; 5941 delete_auto_save_files = 1;
5953 5942
5943 DEFVAR_LISP ("case-fold-search", Vcase_fold_search,
5944 doc: /* Non-nil if searches and matches should ignore case. */);
5945 Vcase_fold_search = Qt;
5946 DEFSYM (Qcase_fold_search, "case-fold-search");
5947 Fmake_variable_buffer_local (Qcase_fold_search);
5948
5954 DEFVAR_LISP ("clone-indirect-buffer-hook", Vclone_indirect_buffer_hook, 5949 DEFVAR_LISP ("clone-indirect-buffer-hook", Vclone_indirect_buffer_hook,
5955 doc: /* Normal hook to run in the new buffer at the end of `make-indirect-buffer'. 5950 doc: /* Normal hook to run in the new buffer at the end of `make-indirect-buffer'.
5956 5951