From: Dmitry Antipov <dmantipov@yandex.ru>
To: Emacs development discussions <emacs-devel@gnu.org>
Cc: Eli Zaretskii <eliz@gnu.org>
Subject: [RFC] using "optimizaiton 1"
Date: Fri, 14 Dec 2012 18:10:10 +0400 [thread overview]
Message-ID: <50CB3342.1020703@yandex.ru> (raw)
[-- Attachment #1: Type: text/plain, Size: 128 bytes --]
Surprisingly, "optimizaiton 1" from redisplay_internal can
handle the case if the region is highlighted, too. Comments?
Dmitry
[-- Attachment #2: redisplay.patch --]
[-- Type: text/plain, Size: 3871 bytes --]
=== modified file 'src/xdisp.c'
--- src/xdisp.c 2012-12-13 16:55:28 +0000
+++ src/xdisp.c 2012-12-14 13:43:30 +0000
@@ -2559,8 +2559,8 @@
#endif /* GLYPH_DEBUG and ENABLE_CHECKING */
-/* Return mark position if current buffer has the region of non-zero length,
- or -1 otherwise. */
+/* Return mark position if current buffer has the region of non-zero
+ length, zero if mark and point are the same, or -1 otherwise. */
static ptrdiff_t
markpos_of_region (void)
@@ -2571,8 +2571,7 @@
{
ptrdiff_t markpos = XMARKER (BVAR (current_buffer, mark))->charpos;
- if (markpos != PT)
- return markpos;
+ return markpos == PT ? 0 : markpos;
}
return -1;
}
@@ -2712,7 +2711,7 @@
and IT->region_end_charpos to the start and end of a visible region
in window IT->w. Set both to -1 to indicate no region. */
markpos = markpos_of_region ();
- if (0 <= markpos
+ if (0 < markpos
/* Maybe highlight only in selected window. */
&& (/* Either show region everywhere. */
highlight_nonselected_windows
@@ -13244,18 +13243,6 @@
clear_garbaged_frames ();
}
-
- /* If showing the region, and mark has changed, we must redisplay
- the whole window. The assignment to this_line_start_pos prevents
- the optimization directly below this if-statement. */
- if (((!NILP (Vtransient_mark_mode)
- && !NILP (BVAR (XBUFFER (w->buffer), mark_active)))
- != !NILP (w->region_showing))
- || (!NILP (w->region_showing)
- && !EQ (w->region_showing,
- Fmarker_position (BVAR (XBUFFER (w->buffer), mark)))))
- CHARPOS (this_line_start_pos) = 0;
-
/* Optimize the case that only the line containing the cursor in the
selected window has changed. Variables starting with this_ are
set in display_line and record information about the line
@@ -13288,7 +13275,8 @@
|| FETCH_BYTE (BYTEPOS (tlbufpos)) == '\n'))
/* Former continuation line has disappeared by becoming empty. */
goto cancel;
- else if (window_outdated (w) || MINI_WINDOW_P (w))
+ else if (window_outdated (w) || MINI_WINDOW_P (w)
+ || 0 <= markpos_of_region ())
{
/* We have to handle the case of continuation around a
wide-column character (see the comment in indent.c around
@@ -13410,6 +13398,10 @@
if (w->cursor_off_p == w->last_cursor_off_p)
goto end_of_redisplay;
}
+#ifdef GLYPH_DEBUG
+ *w->desired_matrix->method = 0;
+ debug_method_add (w, "optimization 2");
+#endif
goto update;
}
/* If highlighting the region, or if the cursor is in the echo area,
@@ -15083,7 +15075,7 @@
/* Can't use this case if highlighting a region. When a
region exists, cursor movement has to do more than just
set the cursor. */
- && markpos_of_region () < 0
+ && markpos_of_region () <= 0
&& NILP (w->region_showing)
&& NILP (Vshow_trailing_whitespace)
/* This code is not used for mini-buffer for the sake of the case
@@ -15752,7 +15744,7 @@
/* If we are highlighting the region, then we just changed
the region, so redisplay to show it. */
- if (0 <= markpos_of_region ())
+ if (0 < markpos_of_region ())
{
clear_glyph_matrix (w->desired_matrix);
if (!try_window (window, startp, 0))
@@ -16457,7 +16449,7 @@
return 0;
/* Can't do this if region may have changed. */
- if (0 <= markpos_of_region ()
+ if (0 < markpos_of_region ()
|| !NILP (w->region_showing)
|| !NILP (Vshow_trailing_whitespace))
return 0;
@@ -17289,7 +17281,7 @@
/* Can't use this if highlighting a region because a cursor movement
will do more than just set the cursor. */
- if (0 <= markpos_of_region ())
+ if (0 < markpos_of_region ())
GIVE_UP (9);
/* Likewise if highlighting trailing whitespace. */
next reply other threads:[~2012-12-14 14:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-14 14:10 Dmitry Antipov [this message]
2012-12-14 14:15 ` [RFC] using "optimizaiton 1" Eli Zaretskii
2012-12-14 16:47 ` Dmitry Antipov
2012-12-15 9:57 ` Eli Zaretskii
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50CB3342.1020703@yandex.ru \
--to=dmantipov@yandex.ru \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).