diff options
| author | Dmitry Antipov | 2013-08-06 10:53:09 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2013-08-06 10:53:09 +0400 |
| commit | e30b79c1c52a4428189ca148c73e7ecc993c6f6a (patch) | |
| tree | a7f60977d16877bbe0f626429243ea19543ed84e /src/buffer.c | |
| parent | 00012b86257f33dd4e08e79b814f4a7ad6010713 (diff) | |
| download | emacs-e30b79c1c52a4428189ca148c73e7ecc993c6f6a.tar.gz emacs-e30b79c1c52a4428189ca148c73e7ecc993c6f6a.zip | |
Use region cache to speedup bidi_find_paragraph_start.
* src/buffer.h (struct buffer): New member bidi_paragraph_cache.
Rename cache_long_line_scans to cache_long_scans.
* src/buffer.c (bset_cache_long_line_scans): Rename to
bset_cache_long_scans.
(Fget_buffer_create, Fmake_indirect_buffer, Fkill_buffer)
(Fbuffer_swap_text, init_buffer_once): Take bidi_paragraph_cache
into account.
(syms_of_buffer): Rename cache-long-line-scans to
cache-long-scans. Adjust docstring.
* src/search.c (newline_cache_on_off):
* src/indent.c (width_run_cache_on_off): Adjust users.
* src/bidi.c (bidi_paragraph_cache_on_off): New function.
(bidi_find_paragraph_start): Use bidi_paragraph_cache if needed.
* src/insdel.c (prepare_to_modify_buffer): Invalidate
bidi_paragraph_cache if enabled.
* doc/lispref/positions.texi (Motion by Screen Lines):
* doc/lispref/display.texi (Truncation): Rename `cache-long-line-scans'
to `cache-long-scans'.
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/buffer.c b/src/buffer.c index f9154d42b03..339175d9078 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -203,9 +203,9 @@ bset_buffer_file_coding_system (struct buffer *b, Lisp_Object val) | |||
| 203 | b->INTERNAL_FIELD (buffer_file_coding_system) = val; | 203 | b->INTERNAL_FIELD (buffer_file_coding_system) = val; |
| 204 | } | 204 | } |
| 205 | static void | 205 | static void |
| 206 | bset_cache_long_line_scans (struct buffer *b, Lisp_Object val) | 206 | bset_cache_long_scans (struct buffer *b, Lisp_Object val) |
| 207 | { | 207 | { |
| 208 | b->INTERNAL_FIELD (cache_long_line_scans) = val; | 208 | b->INTERNAL_FIELD (cache_long_scans) = val; |
| 209 | } | 209 | } |
| 210 | static void | 210 | static void |
| 211 | bset_case_fold_search (struct buffer *b, Lisp_Object val) | 211 | bset_case_fold_search (struct buffer *b, Lisp_Object val) |
| @@ -583,6 +583,7 @@ even if it is dead. The return value is never nil. */) | |||
| 583 | 583 | ||
| 584 | b->newline_cache = 0; | 584 | b->newline_cache = 0; |
| 585 | b->width_run_cache = 0; | 585 | b->width_run_cache = 0; |
| 586 | b->bidi_paragraph_cache = 0; | ||
| 586 | bset_width_table (b, Qnil); | 587 | bset_width_table (b, Qnil); |
| 587 | b->prevent_redisplay_optimizations_p = 1; | 588 | b->prevent_redisplay_optimizations_p = 1; |
| 588 | 589 | ||
| @@ -806,6 +807,7 @@ CLONE nil means the indirect buffer's state is reset to default values. */) | |||
| 806 | 807 | ||
| 807 | b->newline_cache = 0; | 808 | b->newline_cache = 0; |
| 808 | b->width_run_cache = 0; | 809 | b->width_run_cache = 0; |
| 810 | b->bidi_paragraph_cache = 0; | ||
| 809 | bset_width_table (b, Qnil); | 811 | bset_width_table (b, Qnil); |
| 810 | 812 | ||
| 811 | name = Fcopy_sequence (name); | 813 | name = Fcopy_sequence (name); |
| @@ -1945,6 +1947,11 @@ cleaning up all windows currently displaying the buffer to be killed. */) | |||
| 1945 | free_region_cache (b->width_run_cache); | 1947 | free_region_cache (b->width_run_cache); |
| 1946 | b->width_run_cache = 0; | 1948 | b->width_run_cache = 0; |
| 1947 | } | 1949 | } |
| 1950 | if (b->bidi_paragraph_cache) | ||
| 1951 | { | ||
| 1952 | free_region_cache (b->bidi_paragraph_cache); | ||
| 1953 | b->bidi_paragraph_cache = 0; | ||
| 1954 | } | ||
| 1948 | bset_width_table (b, Qnil); | 1955 | bset_width_table (b, Qnil); |
| 1949 | unblock_input (); | 1956 | unblock_input (); |
| 1950 | bset_undo_list (b, Qnil); | 1957 | bset_undo_list (b, Qnil); |
| @@ -2355,6 +2362,7 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, | |||
| 2355 | current_buffer->clip_changed = 1; other_buffer->clip_changed = 1; | 2362 | current_buffer->clip_changed = 1; other_buffer->clip_changed = 1; |
| 2356 | swapfield (newline_cache, struct region_cache *); | 2363 | swapfield (newline_cache, struct region_cache *); |
| 2357 | swapfield (width_run_cache, struct region_cache *); | 2364 | swapfield (width_run_cache, struct region_cache *); |
| 2365 | swapfield (bidi_paragraph_cache, struct region_cache *); | ||
| 2358 | current_buffer->prevent_redisplay_optimizations_p = 1; | 2366 | current_buffer->prevent_redisplay_optimizations_p = 1; |
| 2359 | other_buffer->prevent_redisplay_optimizations_p = 1; | 2367 | other_buffer->prevent_redisplay_optimizations_p = 1; |
| 2360 | swapfield (overlays_before, struct Lisp_Overlay *); | 2368 | swapfield (overlays_before, struct Lisp_Overlay *); |
| @@ -5169,7 +5177,7 @@ init_buffer_once (void) | |||
| 5169 | bset_buffer_file_coding_system (&buffer_defaults, Qnil); | 5177 | bset_buffer_file_coding_system (&buffer_defaults, Qnil); |
| 5170 | XSETFASTINT (BVAR (&buffer_defaults, fill_column), 70); | 5178 | XSETFASTINT (BVAR (&buffer_defaults, fill_column), 70); |
| 5171 | XSETFASTINT (BVAR (&buffer_defaults, left_margin), 0); | 5179 | XSETFASTINT (BVAR (&buffer_defaults, left_margin), 0); |
| 5172 | bset_cache_long_line_scans (&buffer_defaults, Qnil); | 5180 | bset_cache_long_scans (&buffer_defaults, Qnil); |
| 5173 | bset_file_truename (&buffer_defaults, Qnil); | 5181 | bset_file_truename (&buffer_defaults, Qnil); |
| 5174 | XSETFASTINT (BVAR (&buffer_defaults, display_count), 0); | 5182 | XSETFASTINT (BVAR (&buffer_defaults, display_count), 0); |
| 5175 | XSETFASTINT (BVAR (&buffer_defaults, left_margin_cols), 0); | 5183 | XSETFASTINT (BVAR (&buffer_defaults, left_margin_cols), 0); |
| @@ -5233,7 +5241,7 @@ init_buffer_once (void) | |||
| 5233 | XSETFASTINT (BVAR (&buffer_local_flags, abbrev_table), idx); ++idx; | 5241 | XSETFASTINT (BVAR (&buffer_local_flags, abbrev_table), idx); ++idx; |
| 5234 | XSETFASTINT (BVAR (&buffer_local_flags, display_table), idx); ++idx; | 5242 | XSETFASTINT (BVAR (&buffer_local_flags, display_table), idx); ++idx; |
| 5235 | XSETFASTINT (BVAR (&buffer_local_flags, syntax_table), idx); ++idx; | 5243 | XSETFASTINT (BVAR (&buffer_local_flags, syntax_table), idx); ++idx; |
| 5236 | XSETFASTINT (BVAR (&buffer_local_flags, cache_long_line_scans), idx); ++idx; | 5244 | XSETFASTINT (BVAR (&buffer_local_flags, cache_long_scans), idx); ++idx; |
| 5237 | XSETFASTINT (BVAR (&buffer_local_flags, category_table), idx); ++idx; | 5245 | XSETFASTINT (BVAR (&buffer_local_flags, category_table), idx); ++idx; |
| 5238 | XSETFASTINT (BVAR (&buffer_local_flags, bidi_display_reordering), idx); ++idx; | 5246 | XSETFASTINT (BVAR (&buffer_local_flags, bidi_display_reordering), idx); ++idx; |
| 5239 | XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_direction), idx); ++idx; | 5247 | XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_direction), idx); ++idx; |
| @@ -6120,8 +6128,8 @@ If the value of the variable is t, undo information is not recorded. */); | |||
| 6120 | DEFVAR_PER_BUFFER ("mark-active", &BVAR (current_buffer, mark_active), Qnil, | 6128 | DEFVAR_PER_BUFFER ("mark-active", &BVAR (current_buffer, mark_active), Qnil, |
| 6121 | doc: /* Non-nil means the mark and region are currently active in this buffer. */); | 6129 | doc: /* Non-nil means the mark and region are currently active in this buffer. */); |
| 6122 | 6130 | ||
| 6123 | DEFVAR_PER_BUFFER ("cache-long-line-scans", &BVAR (current_buffer, cache_long_line_scans), Qnil, | 6131 | DEFVAR_PER_BUFFER ("cache-long-scans", &BVAR (current_buffer, cache_long_scans), Qnil, |
| 6124 | doc: /* Non-nil means that Emacs should use caches to handle long lines more quickly. | 6132 | doc: /* Non-nil means that Emacs should use caches in attempt to speedup buffer scans. |
| 6125 | 6133 | ||
| 6126 | Normally, the line-motion functions work by scanning the buffer for | 6134 | Normally, the line-motion functions work by scanning the buffer for |
| 6127 | newlines. Columnar operations (like `move-to-column' and | 6135 | newlines. Columnar operations (like `move-to-column' and |
| @@ -6131,18 +6139,24 @@ buffer's lines are very long (say, more than 500 characters), these | |||
| 6131 | motion functions will take longer to execute. Emacs may also take | 6139 | motion functions will take longer to execute. Emacs may also take |
| 6132 | longer to update the display. | 6140 | longer to update the display. |
| 6133 | 6141 | ||
| 6134 | If `cache-long-line-scans' is non-nil, these motion functions cache the | 6142 | If `cache-long-scans' is non-nil, these motion functions cache the |
| 6135 | results of their scans, and consult the cache to avoid rescanning | 6143 | results of their scans, and consult the cache to avoid rescanning |
| 6136 | regions of the buffer until the text is modified. The caches are most | 6144 | regions of the buffer until the text is modified. The caches are most |
| 6137 | beneficial when they prevent the most searching---that is, when the | 6145 | beneficial when they prevent the most searching---that is, when the |
| 6138 | buffer contains long lines and large regions of characters with the | 6146 | buffer contains long lines and large regions of characters with the |
| 6139 | same, fixed screen width. | 6147 | same, fixed screen width. |
| 6140 | 6148 | ||
| 6141 | When `cache-long-line-scans' is non-nil, processing short lines will | 6149 | When `cache-long-scans' is non-nil, processing short lines will |
| 6142 | become slightly slower (because of the overhead of consulting the | 6150 | become slightly slower (because of the overhead of consulting the |
| 6143 | cache), and the caches will use memory roughly proportional to the | 6151 | cache), and the caches will use memory roughly proportional to the |
| 6144 | number of newlines and characters whose screen width varies. | 6152 | number of newlines and characters whose screen width varies. |
| 6145 | 6153 | ||
| 6154 | Bidirectional editing also requires buffer scans to find paragraph | ||
| 6155 | separators. If you have large paragraphs or no paragraph separators | ||
| 6156 | at all, these scans may be slow. If `cache-long-scans' is non-nil, | ||
| 6157 | results of these scans are cached. This doesn't help too much if | ||
| 6158 | paragraphs are of the reasonable (few thousands of characters) size. | ||
| 6159 | |||
| 6146 | The caches require no explicit maintenance; their accuracy is | 6160 | The caches require no explicit maintenance; their accuracy is |
| 6147 | maintained internally by the Emacs primitives. Enabling or disabling | 6161 | maintained internally by the Emacs primitives. Enabling or disabling |
| 6148 | the cache should not affect the behavior of any of the motion | 6162 | the cache should not affect the behavior of any of the motion |