diff options
| author | Joakim Verona | 2012-12-13 09:11:57 +0100 |
|---|---|---|
| committer | Joakim Verona | 2012-12-13 09:11:57 +0100 |
| commit | 8186a9f04f4cdbc5af8d78aa1a8128434676b94f (patch) | |
| tree | 89cb779abbb484561a37ea64d91f942f20a4befa /src | |
| parent | ac6e1d495b144d9053846728c993383517b99a21 (diff) | |
| parent | 40d1e43460b2f642bf1b4255a903c8ff2311b5f6 (diff) | |
| download | emacs-8186a9f04f4cdbc5af8d78aa1a8128434676b94f.tar.gz emacs-8186a9f04f4cdbc5af8d78aa1a8128434676b94f.zip | |
auto upstream
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 4173c82da54..aa1657bd72c 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -2564,8 +2564,24 @@ check_window_end (struct window *w) | |||
| 2564 | 2564 | ||
| 2565 | #endif /* GLYPH_DEBUG and ENABLE_CHECKING */ | 2565 | #endif /* GLYPH_DEBUG and ENABLE_CHECKING */ |
| 2566 | 2566 | ||
| 2567 | /* Return mark position if current buffer has the region of non-zero length, | ||
| 2568 | or -1 otherwise. */ | ||
| 2569 | |||
| 2570 | static ptrdiff_t | ||
| 2571 | markpos_of_region (void) | ||
| 2572 | { | ||
| 2573 | if (!NILP (Vtransient_mark_mode) | ||
| 2574 | && !NILP (BVAR (current_buffer, mark_active)) | ||
| 2575 | && XMARKER (BVAR (current_buffer, mark))->buffer != NULL) | ||
| 2576 | { | ||
| 2577 | ptrdiff_t markpos = XMARKER (BVAR (current_buffer, mark))->charpos; | ||
| 2578 | |||
| 2579 | if (markpos != PT) | ||
| 2580 | return markpos; | ||
| 2581 | } | ||
| 2582 | return -1; | ||
| 2583 | } | ||
| 2567 | 2584 | ||
| 2568 | |||
| 2569 | /*********************************************************************** | 2585 | /*********************************************************************** |
| 2570 | Iterator initialization | 2586 | Iterator initialization |
| 2571 | ***********************************************************************/ | 2587 | ***********************************************************************/ |
| @@ -2594,7 +2610,7 @@ init_iterator (struct it *it, struct window *w, | |||
| 2594 | ptrdiff_t charpos, ptrdiff_t bytepos, | 2610 | ptrdiff_t charpos, ptrdiff_t bytepos, |
| 2595 | struct glyph_row *row, enum face_id base_face_id) | 2611 | struct glyph_row *row, enum face_id base_face_id) |
| 2596 | { | 2612 | { |
| 2597 | int highlight_region_p; | 2613 | ptrdiff_t markpos; |
| 2598 | enum face_id remapped_base_face_id = base_face_id; | 2614 | enum face_id remapped_base_face_id = base_face_id; |
| 2599 | 2615 | ||
| 2600 | /* Some precondition checks. */ | 2616 | /* Some precondition checks. */ |
| @@ -2697,16 +2713,10 @@ init_iterator (struct it *it, struct window *w, | |||
| 2697 | /* Are multibyte characters enabled in current_buffer? */ | 2713 | /* Are multibyte characters enabled in current_buffer? */ |
| 2698 | it->multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters)); | 2714 | it->multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters)); |
| 2699 | 2715 | ||
| 2700 | /* Non-zero if we should highlight the region. */ | 2716 | /* If visible region is of non-zero length, set IT->region_beg_charpos |
| 2701 | highlight_region_p | 2717 | and IT->region_end_charpos to the start and end of a visible region |
| 2702 | = (!NILP (Vtransient_mark_mode) | 2718 | in window IT->w. Set both to -1 to indicate no region. */ |
| 2703 | && !NILP (BVAR (current_buffer, mark_active)) | 2719 | if ((markpos = markpos_of_region ()) != -1 |
| 2704 | && XMARKER (BVAR (current_buffer, mark))->buffer != 0); | ||
| 2705 | |||
| 2706 | /* Set IT->region_beg_charpos and IT->region_end_charpos to the | ||
| 2707 | start and end of a visible region in window IT->w. Set both to | ||
| 2708 | -1 to indicate no region. */ | ||
| 2709 | if (highlight_region_p | ||
| 2710 | /* Maybe highlight only in selected window. */ | 2720 | /* Maybe highlight only in selected window. */ |
| 2711 | && (/* Either show region everywhere. */ | 2721 | && (/* Either show region everywhere. */ |
| 2712 | highlight_nonselected_windows | 2722 | highlight_nonselected_windows |
| @@ -2718,7 +2728,6 @@ init_iterator (struct it *it, struct window *w, | |||
| 2718 | && WINDOWP (minibuf_selected_window) | 2728 | && WINDOWP (minibuf_selected_window) |
| 2719 | && w == XWINDOW (minibuf_selected_window)))) | 2729 | && w == XWINDOW (minibuf_selected_window)))) |
| 2720 | { | 2730 | { |
| 2721 | ptrdiff_t markpos = marker_position (BVAR (current_buffer, mark)); | ||
| 2722 | it->region_beg_charpos = min (PT, markpos); | 2731 | it->region_beg_charpos = min (PT, markpos); |
| 2723 | it->region_end_charpos = max (PT, markpos); | 2732 | it->region_end_charpos = max (PT, markpos); |
| 2724 | } | 2733 | } |
| @@ -15134,8 +15143,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste | |||
| 15134 | /* Can't use this case if highlighting a region. When a | 15143 | /* Can't use this case if highlighting a region. When a |
| 15135 | region exists, cursor movement has to do more than just | 15144 | region exists, cursor movement has to do more than just |
| 15136 | set the cursor. */ | 15145 | set the cursor. */ |
| 15137 | && !(!NILP (Vtransient_mark_mode) | 15146 | && (markpos_of_region () == -1) |
| 15138 | && !NILP (BVAR (current_buffer, mark_active))) | ||
| 15139 | && NILP (w->region_showing) | 15147 | && NILP (w->region_showing) |
| 15140 | && NILP (Vshow_trailing_whitespace) | 15148 | && NILP (Vshow_trailing_whitespace) |
| 15141 | /* This code is not used for mini-buffer for the sake of the case | 15149 | /* This code is not used for mini-buffer for the sake of the case |
| @@ -15804,8 +15812,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) | |||
| 15804 | 15812 | ||
| 15805 | /* If we are highlighting the region, then we just changed | 15813 | /* If we are highlighting the region, then we just changed |
| 15806 | the region, so redisplay to show it. */ | 15814 | the region, so redisplay to show it. */ |
| 15807 | if (!NILP (Vtransient_mark_mode) | 15815 | if (markpos_of_region () != -1) |
| 15808 | && !NILP (BVAR (current_buffer, mark_active))) | ||
| 15809 | { | 15816 | { |
| 15810 | clear_glyph_matrix (w->desired_matrix); | 15817 | clear_glyph_matrix (w->desired_matrix); |
| 15811 | if (!try_window (window, startp, 0)) | 15818 | if (!try_window (window, startp, 0)) |
| @@ -16524,8 +16531,7 @@ try_window_reusing_current_matrix (struct window *w) | |||
| 16524 | return 0; | 16531 | return 0; |
| 16525 | 16532 | ||
| 16526 | /* Can't do this if region may have changed. */ | 16533 | /* Can't do this if region may have changed. */ |
| 16527 | if ((!NILP (Vtransient_mark_mode) | 16534 | if ((markpos_of_region () != -1) |
| 16528 | && !NILP (BVAR (current_buffer, mark_active))) | ||
| 16529 | || !NILP (w->region_showing) | 16535 | || !NILP (w->region_showing) |
| 16530 | || !NILP (Vshow_trailing_whitespace)) | 16536 | || !NILP (Vshow_trailing_whitespace)) |
| 16531 | return 0; | 16537 | return 0; |
| @@ -17364,8 +17370,7 @@ try_window_id (struct window *w) | |||
| 17364 | 17370 | ||
| 17365 | /* Can't use this if highlighting a region because a cursor movement | 17371 | /* Can't use this if highlighting a region because a cursor movement |
| 17366 | will do more than just set the cursor. */ | 17372 | will do more than just set the cursor. */ |
| 17367 | if (!NILP (Vtransient_mark_mode) | 17373 | if (markpos_of_region () != -1) |
| 17368 | && !NILP (BVAR (current_buffer, mark_active))) | ||
| 17369 | GIVE_UP (9); | 17374 | GIVE_UP (9); |
| 17370 | 17375 | ||
| 17371 | /* Likewise if highlighting trailing whitespace. */ | 17376 | /* Likewise if highlighting trailing whitespace. */ |