diff options
| author | Dmitry Antipov | 2012-12-13 12:04:40 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-12-13 12:04:40 +0400 |
| commit | 40d1e43460b2f642bf1b4255a903c8ff2311b5f6 (patch) | |
| tree | 685c228dc7638ab0b32a77097cb68d1d8e7541b5 /src | |
| parent | ba30c70fa0afecc413b0bdf0bed0788c52a099d3 (diff) | |
| download | emacs-40d1e43460b2f642bf1b4255a903c8ff2311b5f6.tar.gz emacs-40d1e43460b2f642bf1b4255a903c8ff2311b5f6.zip | |
Minor redisplay optimization when the region length is zero.
* xdisp.c (markpos_of_region): New function.
(init_iterator): Do not highlight the region of zero length.
(redisplay_window): Check whether the region is of non-zero length.
(try_cursor_movement): Allow if the region length is zero.
(try_window_reusing_current_matrix, try_window_id): Likewise.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/xdisp.c | 47 |
2 files changed, 35 insertions, 21 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b7bb772d266..f513e80408d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2012-12-13 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | Minor redisplay optimization when the region length is zero. | ||
| 4 | * xdisp.c (markpos_of_region): New function. | ||
| 5 | (init_iterator): Do not highlight the region of zero length. | ||
| 6 | (redisplay_window): Check whether the region is of non-zero length. | ||
| 7 | (try_cursor_movement): Allow if the region length is zero. | ||
| 8 | (try_window_reusing_current_matrix, try_window_id): Likewise. | ||
| 9 | |||
| 1 | 2012-12-13 Eli Zaretskii <eliz@gnu.org> | 10 | 2012-12-13 Eli Zaretskii <eliz@gnu.org> |
| 2 | 11 | ||
| 3 | * search.c (search_buffer): Check the inverse translations of each | 12 | * search.c (search_buffer): Check the inverse translations of each |
diff --git a/src/xdisp.c b/src/xdisp.c index aead10a7b9b..2801f3def10 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -2559,8 +2559,24 @@ check_window_end (struct window *w) | |||
| 2559 | 2559 | ||
| 2560 | #endif /* GLYPH_DEBUG and ENABLE_CHECKING */ | 2560 | #endif /* GLYPH_DEBUG and ENABLE_CHECKING */ |
| 2561 | 2561 | ||
| 2562 | /* Return mark position if current buffer has the region of non-zero length, | ||
| 2563 | or -1 otherwise. */ | ||
| 2564 | |||
| 2565 | static ptrdiff_t | ||
| 2566 | markpos_of_region (void) | ||
| 2567 | { | ||
| 2568 | if (!NILP (Vtransient_mark_mode) | ||
| 2569 | && !NILP (BVAR (current_buffer, mark_active)) | ||
| 2570 | && XMARKER (BVAR (current_buffer, mark))->buffer != NULL) | ||
| 2571 | { | ||
| 2572 | ptrdiff_t markpos = XMARKER (BVAR (current_buffer, mark))->charpos; | ||
| 2573 | |||
| 2574 | if (markpos != PT) | ||
| 2575 | return markpos; | ||
| 2576 | } | ||
| 2577 | return -1; | ||
| 2578 | } | ||
| 2562 | 2579 | ||
| 2563 | |||
| 2564 | /*********************************************************************** | 2580 | /*********************************************************************** |
| 2565 | Iterator initialization | 2581 | Iterator initialization |
| 2566 | ***********************************************************************/ | 2582 | ***********************************************************************/ |
| @@ -2589,7 +2605,7 @@ init_iterator (struct it *it, struct window *w, | |||
| 2589 | ptrdiff_t charpos, ptrdiff_t bytepos, | 2605 | ptrdiff_t charpos, ptrdiff_t bytepos, |
| 2590 | struct glyph_row *row, enum face_id base_face_id) | 2606 | struct glyph_row *row, enum face_id base_face_id) |
| 2591 | { | 2607 | { |
| 2592 | int highlight_region_p; | 2608 | ptrdiff_t markpos; |
| 2593 | enum face_id remapped_base_face_id = base_face_id; | 2609 | enum face_id remapped_base_face_id = base_face_id; |
| 2594 | 2610 | ||
| 2595 | /* Some precondition checks. */ | 2611 | /* Some precondition checks. */ |
| @@ -2692,16 +2708,10 @@ init_iterator (struct it *it, struct window *w, | |||
| 2692 | /* Are multibyte characters enabled in current_buffer? */ | 2708 | /* Are multibyte characters enabled in current_buffer? */ |
| 2693 | it->multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters)); | 2709 | it->multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters)); |
| 2694 | 2710 | ||
| 2695 | /* Non-zero if we should highlight the region. */ | 2711 | /* If visible region is of non-zero length, set IT->region_beg_charpos |
| 2696 | highlight_region_p | 2712 | and IT->region_end_charpos to the start and end of a visible region |
| 2697 | = (!NILP (Vtransient_mark_mode) | 2713 | in window IT->w. Set both to -1 to indicate no region. */ |
| 2698 | && !NILP (BVAR (current_buffer, mark_active)) | 2714 | if ((markpos = markpos_of_region ()) != -1 |
| 2699 | && XMARKER (BVAR (current_buffer, mark))->buffer != 0); | ||
| 2700 | |||
| 2701 | /* Set IT->region_beg_charpos and IT->region_end_charpos to the | ||
| 2702 | start and end of a visible region in window IT->w. Set both to | ||
| 2703 | -1 to indicate no region. */ | ||
| 2704 | if (highlight_region_p | ||
| 2705 | /* Maybe highlight only in selected window. */ | 2715 | /* Maybe highlight only in selected window. */ |
| 2706 | && (/* Either show region everywhere. */ | 2716 | && (/* Either show region everywhere. */ |
| 2707 | highlight_nonselected_windows | 2717 | highlight_nonselected_windows |
| @@ -2713,7 +2723,6 @@ init_iterator (struct it *it, struct window *w, | |||
| 2713 | && WINDOWP (minibuf_selected_window) | 2723 | && WINDOWP (minibuf_selected_window) |
| 2714 | && w == XWINDOW (minibuf_selected_window)))) | 2724 | && w == XWINDOW (minibuf_selected_window)))) |
| 2715 | { | 2725 | { |
| 2716 | ptrdiff_t markpos = marker_position (BVAR (current_buffer, mark)); | ||
| 2717 | it->region_beg_charpos = min (PT, markpos); | 2726 | it->region_beg_charpos = min (PT, markpos); |
| 2718 | it->region_end_charpos = max (PT, markpos); | 2727 | it->region_end_charpos = max (PT, markpos); |
| 2719 | } | 2728 | } |
| @@ -15073,8 +15082,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste | |||
| 15073 | /* Can't use this case if highlighting a region. When a | 15082 | /* Can't use this case if highlighting a region. When a |
| 15074 | region exists, cursor movement has to do more than just | 15083 | region exists, cursor movement has to do more than just |
| 15075 | set the cursor. */ | 15084 | set the cursor. */ |
| 15076 | && !(!NILP (Vtransient_mark_mode) | 15085 | && (markpos_of_region () == -1) |
| 15077 | && !NILP (BVAR (current_buffer, mark_active))) | ||
| 15078 | && NILP (w->region_showing) | 15086 | && NILP (w->region_showing) |
| 15079 | && NILP (Vshow_trailing_whitespace) | 15087 | && NILP (Vshow_trailing_whitespace) |
| 15080 | /* This code is not used for mini-buffer for the sake of the case | 15088 | /* This code is not used for mini-buffer for the sake of the case |
| @@ -15743,8 +15751,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) | |||
| 15743 | 15751 | ||
| 15744 | /* If we are highlighting the region, then we just changed | 15752 | /* If we are highlighting the region, then we just changed |
| 15745 | the region, so redisplay to show it. */ | 15753 | the region, so redisplay to show it. */ |
| 15746 | if (!NILP (Vtransient_mark_mode) | 15754 | if (markpos_of_region () != -1) |
| 15747 | && !NILP (BVAR (current_buffer, mark_active))) | ||
| 15748 | { | 15755 | { |
| 15749 | clear_glyph_matrix (w->desired_matrix); | 15756 | clear_glyph_matrix (w->desired_matrix); |
| 15750 | if (!try_window (window, startp, 0)) | 15757 | if (!try_window (window, startp, 0)) |
| @@ -16449,8 +16456,7 @@ try_window_reusing_current_matrix (struct window *w) | |||
| 16449 | return 0; | 16456 | return 0; |
| 16450 | 16457 | ||
| 16451 | /* Can't do this if region may have changed. */ | 16458 | /* Can't do this if region may have changed. */ |
| 16452 | if ((!NILP (Vtransient_mark_mode) | 16459 | if ((markpos_of_region () != -1) |
| 16453 | && !NILP (BVAR (current_buffer, mark_active))) | ||
| 16454 | || !NILP (w->region_showing) | 16460 | || !NILP (w->region_showing) |
| 16455 | || !NILP (Vshow_trailing_whitespace)) | 16461 | || !NILP (Vshow_trailing_whitespace)) |
| 16456 | return 0; | 16462 | return 0; |
| @@ -17282,8 +17288,7 @@ try_window_id (struct window *w) | |||
| 17282 | 17288 | ||
| 17283 | /* Can't use this if highlighting a region because a cursor movement | 17289 | /* Can't use this if highlighting a region because a cursor movement |
| 17284 | will do more than just set the cursor. */ | 17290 | will do more than just set the cursor. */ |
| 17285 | if (!NILP (Vtransient_mark_mode) | 17291 | if (markpos_of_region () != -1) |
| 17286 | && !NILP (BVAR (current_buffer, mark_active))) | ||
| 17287 | GIVE_UP (9); | 17292 | GIVE_UP (9); |
| 17288 | 17293 | ||
| 17289 | /* Likewise if highlighting trailing whitespace. */ | 17294 | /* Likewise if highlighting trailing whitespace. */ |