all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Antipov <dmantipov@yandex.ru>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: 'struct window' cleanup #3
Date: Sun, 01 Jul 2012 19:05:31 +0400	[thread overview]
Message-ID: <4FF0673B.9010002@yandex.ru> (raw)
In-Reply-To: <838vf88s3i.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 831 bytes --]

One more minor simplification: W->region_showing may be only nil or t,
so it may be reduced to a bitfield.

Hard case:

   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)))))

There are two possible cases:

   - both w->region_showing and Fmarker_position (BVAR (XBUFFER (w->buffer), mark))
     are nil;
   - w->region_showing is t and Fmarker_position (BVAR (XBUFFER (w->buffer), mark))
     is a number, so !EQ (...) is always non-zero.

So if-statement may be simplified to:

   if (((!NILP (Vtransient_mark_mode)
	&& !NILP (BVAR (XBUFFER (w->buffer), mark_active)))
        != w->region_showing) || w->region_showing)

Dmitry

[-- Attachment #2: region_showing.patch --]
[-- Type: text/plain, Size: 3652 bytes --]

=== modified file 'src/window.h'
--- src/window.h	2012-06-29 11:48:08 +0000
+++ src/window.h	2012-07-01 09:55:44 +0000
@@ -198,10 +198,6 @@
        as long as the window shows that buffer.  */
     Lisp_Object base_line_pos;
 
-    /* If we have highlighted the region (or any part of it),
-       this is the mark position that we used, as an integer.  */
-    Lisp_Object region_showing;
-
     /* The column number currently displayed in this window's mode line,
        or nil if column numbers are not being displayed.  */
     Lisp_Object column_number_displayed;
@@ -289,6 +285,9 @@
        was last updated.  */
     unsigned last_had_star : 1;
 
+    /* Non-zero if we have highlighted the region (or any part of it).  */
+    unsigned region_showing : 1;
+
     /* Non-zero means current value of `start'
        was the beginning of a line when it was chosen.  */
     unsigned start_at_line_beg : 1;

=== modified file 'src/xdisp.c'
--- src/xdisp.c	2012-06-29 18:52:54 +0000
+++ src/xdisp.c	2012-07-01 14:56:24 +0000
@@ -11202,7 +11202,7 @@
 	      != w->last_had_star)
 	  || ((!NILP (Vtransient_mark_mode)
 	       && !NILP (BVAR (XBUFFER (w->buffer), mark_active)))
-	      != !NILP (w->region_showing)))
+	      != w->region_showing))
 	{
 	  struct buffer *prev = current_buffer;
 	  ptrdiff_t count = SPECPDL_INDEX ();
@@ -11400,7 +11400,7 @@
 	      != w->last_had_star)
 	  || ((!NILP (Vtransient_mark_mode)
 	       && !NILP (BVAR (XBUFFER (w->buffer), mark_active)))
-	      != !NILP (w->region_showing)))
+	      != w->region_showing))
 	{
 	  struct buffer *prev = current_buffer;
 	  ptrdiff_t count = SPECPDL_INDEX ();
@@ -13105,10 +13105,7 @@
      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)))))
+       != w->region_showing) || w->region_showing)
     CHARPOS (this_line_start_pos) = 0;
 
   /* Optimize the case that only the line containing the cursor in the
@@ -13276,7 +13273,7 @@
 	       && (EQ (selected_window,
 		       BVAR (current_buffer, last_selected_window))
 		   || highlight_nonselected_windows)
-	       && NILP (w->region_showing)
+	       && !w->region_showing
 	       && NILP (Vshow_trailing_whitespace)
 	       && !cursor_in_echo_area)
 	{
@@ -14953,7 +14950,7 @@
          set the cursor.  */
       && !(!NILP (Vtransient_mark_mode)
 	   && !NILP (BVAR (current_buffer, mark_active)))
-      && NILP (w->region_showing)
+      && !w->region_showing
       && NILP (Vshow_trailing_whitespace)
       /* This code is not used for mini-buffer for the sake of the case
 	 of redisplaying to replace an echo area message; since in
@@ -16324,7 +16321,7 @@
   /* Can't do this if region may have changed.  */
   if ((!NILP (Vtransient_mark_mode)
        && !NILP (BVAR (current_buffer, mark_active)))
-      || !NILP (w->region_showing)
+      || w->region_showing
       || !NILP (Vshow_trailing_whitespace))
     return 0;
 
@@ -17156,7 +17153,7 @@
     GIVE_UP (11);
 
   /* Likewise if showing a region.  */
-  if (!NILP (w->region_showing))
+  if (w->region_showing)
     GIVE_UP (10);
 
   /* Can't use this if overlay arrow position and/or string have
@@ -19134,7 +19131,7 @@
     }
 
   /* Is IT->w showing the region?  */
-  it->w->region_showing = it->region_beg_charpos > 0 ? Qt : Qnil;
+  it->w->region_showing = it->region_beg_charpos > 0;
 
   /* Clear the result glyph row and enable it.  */
   prepare_desired_row (row);


  reply	other threads:[~2012-07-01 15:05 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-25  8:56 'struct window' cleanup #2 Dmitry Antipov
2012-06-25 14:22 ` John Wiegley
2012-06-25 14:42   ` Dmitry Antipov
2012-06-25 14:27 ` Paul Eggert
2012-06-25 14:53 ` Stefan Monnier
2012-06-25 16:30   ` Dmitry Antipov
2012-06-25 16:35   ` martin rudalics
2012-06-25 16:49     ` Dmitry Antipov
2012-06-26  7:26       ` martin rudalics
2012-06-26  9:06         ` Dmitry Antipov
2012-06-26 15:37           ` Eli Zaretskii
2012-06-26 15:32         ` Eli Zaretskii
2012-06-26 16:49           ` Dmitry Antipov
2012-06-26 17:12             ` Eli Zaretskii
2012-06-27  0:42           ` Stefan Monnier
2012-06-27  3:03             ` Eli Zaretskii
2012-06-27  7:10               ` 'struct window' cleanup #3 Dmitry Antipov
2012-06-27 13:32                 ` Stefan Monnier
2012-06-27 17:37                   ` Eli Zaretskii
2012-06-27 17:24                 ` Eli Zaretskii
2012-06-27 17:59                   ` Dmitry Antipov
2012-06-27 19:36                     ` Eli Zaretskii
2012-07-01 15:05                       ` Dmitry Antipov [this message]
2012-07-01 15:42                         ` Andreas Schwab
2012-06-28 12:51                   ` Dmitry Antipov
2012-06-27  7:06           ` 'struct window' cleanup #2 martin rudalics
2012-06-27 16:59             ` Eli Zaretskii
2012-06-25 16:39 ` 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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FF0673B.9010002@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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.