unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Antipov <dmantipov@yandex.ru>
To: Emacs development discussions <emacs-devel@gnu.org>
Subject: 'struct window' cleanup #2
Date: Mon, 25 Jun 2012 12:56:22 +0400	[thread overview]
Message-ID: <4FE827B6.6020306@yandex.ru> (raw)

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

For a `struct window', changing the type of `last_point', `last_modified'
and `last_overlay_modified' from Lisp_Object to appropriate integral
value eliminates a lot of useless Lisp_Object <-> {EMACS_INT, ptrdiff_t}
conversions in a window and redisplay code; and, of course, lesser Lisp_Objects
means a bit faster GC. OK to install?

Dmitry

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

=== modified file 'admin/ChangeLog'
--- admin/ChangeLog	2012-06-24 16:18:41 +0000
+++ admin/ChangeLog	2012-06-25 08:40:47 +0000
@@ -1,3 +1,10 @@
+2012-06-25  Dmitry Antipov  <dmantipov@yandex.ru>
+
+	* coccinelle/window_members.cocci: Semantic patch to adjust all
+	users after changing `last_modified' and `last_overlay_modified'
+	from Lisp_Object to EMACS_INT, and `last_point' from Lisp_Object
+	to ptrdiff_t in a `struct window'.
+
 2012-06-24  Dmitry Antipov  <dmantipov@yandex.ru>
 
 	First Coccinelle semantic patch.

=== added file 'admin/coccinelle/window_members.cocci'
--- admin/coccinelle/window_members.cocci	1970-01-01 00:00:00 +0000
+++ admin/coccinelle/window_members.cocci	2012-06-25 08:40:47 +0000
@@ -0,0 +1,44 @@
+// Adjust all users after changing `last_modified' and `last_overlay_modified'
+// from Lisp_Object to EMACS_INT, and `last_point' from Lisp_Object to 
+// ptrdiff_t in a `struct window'.
+@@
+expression E;
+identifier W;
+@@
+(
+- W->last_point = make_numer (E)
++ W->last_point = E
+|
+- XSETFASTINT (W->last_point, E)
++ W->last_point = E
+|
+- XINT (W->last_point)
++ W->last_point
+|
+- XFASTINT (W->last_point)
++ W->last_point
+|
+- XSETFASTINT (XWINDOW (W)->last_modified, E)
++ XWINDOW (W)->last_modified = E
+|
+- XSETFASTINT (W->last_modified, E)
++ W->last_modified = E
+|
+- W->last_modified = make_number (E)
++ W->last_modified = E
+|
+- XFASTINT (W->last_modified)
++ W->last_modified
+|
+- XSETFASTINT (XWINDOW (W)->last_overlay_modified, E)
++ XWINDOW (W)->last_overlay_modified = E
+|
+- XSETFASTINT (W->last_overlay_modified, E)
++ W->last_overlay_modified = E
+|
+- W->last_overlay_modifed = make_number (E)
++ W->last_overlay_modifed = E
+|
+- XFASTINT (W->last_overlay_modified)
++ W->last_overlay_modified
+)

=== modified file 'src/ChangeLog'
--- src/ChangeLog	2012-06-25 07:54:45 +0000
+++ src/ChangeLog	2012-06-25 08:42:44 +0000
@@ -1,3 +1,10 @@
+2012-06-25  Dmitry Antipov  <dmantipov@yandex.ru>
+
+	* window.h (struct window): For a `struct window', change
+	`last_modified' and `last_overlay_modified' from Lisp_Object
+	to EMACS_INT, and `last_point' from Lisp_Object to ptrdiff_t.
+	Adjust users accordingly.
+
 2012-06-25  Paul Eggert  <eggert@cs.ucla.edu>
 
 	* gtkutil.c (get_utf8_string): Remove redundant assignment.

=== modified file 'src/frame.c'
--- src/frame.c	2012-06-19 06:49:50 +0000
+++ src/frame.c	2012-06-25 08:40:47 +0000
@@ -131,7 +131,7 @@
 {
   struct window *w = XWINDOW (window);
 
-  XSETFASTINT (w->last_modified, 0);
+  w->last_modified = 0;
   XSETFASTINT (w->top_line, XFASTINT (w->top_line) + n);
   XSETFASTINT (w->total_lines, XFASTINT (w->total_lines) - n);
 

=== modified file 'src/minibuf.c'
--- src/minibuf.c	2012-06-19 17:05:41 +0000
+++ src/minibuf.c	2012-06-25 08:40:47 +0000
@@ -888,8 +888,8 @@
 
   /* Make sure minibuffer window is erased, not ignored.  */
   windows_or_buffers_changed++;
-  XSETFASTINT (XWINDOW (window)->last_modified, 0);
-  XSETFASTINT (XWINDOW (window)->last_overlay_modified, 0);
+  XWINDOW (window)->last_modified = 0;
+  XWINDOW (window)->last_overlay_modified = 0;
 
   /* In case the previous minibuffer displayed in this miniwindow is
      dead, we may keep displaying this buffer (tho it's inactive), so reset it,

=== modified file 'src/window.c'
--- src/window.c	2012-06-19 16:56:28 +0000
+++ src/window.c	2012-06-25 08:40:47 +0000
@@ -1314,8 +1314,8 @@
 
   if (! NILP (update)
       && ! (! NILP (w->window_end_valid)
-	    && XFASTINT (w->last_modified) >= BUF_MODIFF (b)
-	    && XFASTINT (w->last_overlay_modified) >= BUF_OVERLAY_MODIFF (b))
+	    && w->last_modified >= BUF_MODIFF (b)
+	    && w->last_overlay_modified >= BUF_OVERLAY_MODIFF (b))
       && !noninteractive)
     {
       struct text_pos startp;
@@ -1398,8 +1398,8 @@
   if (NILP (noforce))
     w->force_start = 1;
   w->update_mode_line = 1;
-  XSETFASTINT (w->last_modified, 0);
-  XSETFASTINT (w->last_overlay_modified, 0);
+  w->last_modified = 0;
+  w->last_overlay_modified = 0;
   if (!EQ (window, selected_window))
     windows_or_buffers_changed++;
 
@@ -1511,8 +1511,8 @@
   if (NILP (w->window_end_valid)
       || current_buffer->clip_changed
       || current_buffer->prevent_redisplay_optimizations_p
-      || XFASTINT (w->last_modified) < BUF_MODIFF (b)
-      || XFASTINT (w->last_overlay_modified) < BUF_OVERLAY_MODIFF (b))
+      || w->last_modified < BUF_MODIFF (b)
+      || w->last_overlay_modified < BUF_OVERLAY_MODIFF (b))
     return Qnil;
 
   if (NILP (line))
@@ -3011,8 +3011,8 @@
 			     buffer);
       w->start_at_line_beg = 0;
       w->force_start = 0;
-      XSETFASTINT (w->last_modified, 0);
-      XSETFASTINT (w->last_overlay_modified, 0);
+      w->last_modified = 0;
+      w->last_overlay_modified = 0;
     }
   /* Maybe we could move this into the `if' but it's not obviously safe and
      I doubt it's worth the trouble.  */
@@ -3298,8 +3298,9 @@
   XSETFASTINT (w->use_time, 0);
   ++sequence_number;
   XSETFASTINT (w->sequence_number, sequence_number);
-  w->temslot = w->last_modified = w->last_overlay_modified = Qnil;
-  XSETFASTINT (w->last_point, 0);
+  w->temslot = Qnil;
+  w->last_modified = w->last_overlay_modified = 0;
+  w->last_point = 0;
   w->last_had_star = 0;
   w->vertical_scroll_bar = Qnil;
   w->left_margin_cols = w->right_margin_cols = Qnil;
@@ -3518,8 +3519,8 @@
     }
 
   /* Clear out some redisplay caches.  */
-  XSETFASTINT (w->last_modified, 0);
-  XSETFASTINT (w->last_overlay_modified, 0);
+  w->last_modified = 0;
+  w->last_overlay_modified = 0;
 }
 
 
@@ -4051,8 +4052,8 @@
       /* Grow the mini-window.  */
       XSETFASTINT (w->top_line, XFASTINT (r->top_line) + XFASTINT (r->total_lines));
       XSETFASTINT (w->total_lines, XFASTINT (w->total_lines) - XINT (value));
-      XSETFASTINT (w->last_modified, 0);
-      XSETFASTINT (w->last_overlay_modified, 0);
+      w->last_modified = 0;
+      w->last_overlay_modified = 0;
 
       adjust_glyphs (f);
       UNBLOCK_INPUT;
@@ -4087,8 +4088,8 @@
 	  XSETFASTINT (w->top_line, XFASTINT (r->top_line) + XFASTINT (r->total_lines));
 	  XSETFASTINT (w->total_lines, 1);
 
-	  XSETFASTINT (w->last_modified, 0);
-	  XSETFASTINT (w->last_overlay_modified, 0);
+	  w->last_modified = 0;
+	  w->last_overlay_modified = 0;
 
 	  adjust_glyphs (f);
 	  UNBLOCK_INPUT;
@@ -4315,8 +4316,8 @@
 					 w->buffer);
 		  w->start_at_line_beg = 1;
 		  w->update_mode_line = 1;
-		  XSETFASTINT (w->last_modified, 0);
-		  XSETFASTINT (w->last_overlay_modified, 0);
+		  w->last_modified = 0;
+		  w->last_overlay_modified = 0;
 		  /* Set force_start so that redisplay_window will run the
 		     window-scroll-functions.  */
 		  w->force_start = 1;
@@ -4461,8 +4462,8 @@
       bytepos = XMARKER (w->start)->bytepos;
       w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n');
       w->update_mode_line = 1;
-      XSETFASTINT (w->last_modified, 0);
-      XSETFASTINT (w->last_overlay_modified, 0);
+      w->last_modified = 0;
+      w->last_overlay_modified = 0;
       /* Set force_start so that redisplay_window will run the
 	 window-scroll-functions.  */
       w->force_start = 1;
@@ -4660,8 +4661,8 @@
       set_marker_restricted_both (w->start, w->buffer, pos, pos_byte);
       w->start_at_line_beg = !NILP (bolp);
       w->update_mode_line = 1;
-      XSETFASTINT (w->last_modified, 0);
-      XSETFASTINT (w->last_overlay_modified, 0);
+      w->last_modified = 0;
+      w->last_overlay_modified = 0;
       /* Set force_start so that redisplay_window will run
 	 the window-scroll-functions.  */
       w->force_start = 1;
@@ -5601,8 +5602,8 @@
 		}
 	    }
 
-	  XSETFASTINT (w->last_modified, 0);
-	  XSETFASTINT (w->last_overlay_modified, 0);
+	  w->last_modified = 0;
+	  w->last_overlay_modified = 0;
 
 	  /* Reinstall the saved buffer and pointers into it.  */
 	  if (NILP (p->buffer))

=== modified file 'src/window.h'
--- src/window.h	2012-06-01 03:41:03 +0000
+++ src/window.h	2012-06-25 08:40:47 +0000
@@ -157,14 +157,6 @@
        bookkeeping.  */
     Lisp_Object temslot;
 
-    /* text.modified of displayed buffer as of last time display
-       completed.  */
-    Lisp_Object last_modified;
-    /* BUF_OVERLAY_MODIFIED of displayed buffer as of last complete update.  */
-    Lisp_Object last_overlay_modified;
-    /* Value of point at that time.  */
-    Lisp_Object last_point;
-
     /* This window's vertical scroll bar.  This field is only for use
        by the window-system-dependent code which implements the
        scroll bars; it can store anything it likes here.  If this
@@ -254,6 +246,17 @@
     struct glyph_matrix *current_matrix;
     struct glyph_matrix *desired_matrix;
 
+    /* Displayed buffer's text modification events counter as of last time
+       display completed.  */
+    EMACS_INT last_modified;
+
+    /* Displayed buffer's overlays modification events counter as of last
+       complete update.  */
+    EMACS_INT last_overlay_modified;
+
+    /* Value of point at that time.  */
+    ptrdiff_t last_point;
+
     /* Scaling factor for the glyph_matrix size calculation in this window.
        Used if window contains many small images or uses proportional fonts,
        as the normal  may yield a matrix which is too small.  */

=== modified file 'src/xdisp.c'
--- src/xdisp.c	2012-06-22 21:17:42 +0000
+++ src/xdisp.c	2012-06-25 08:40:47 +0000
@@ -12510,8 +12510,8 @@
   int unchanged_p = 1;
 
   /* If text or overlays have changed, see where.  */
-  if (XFASTINT (w->last_modified) < MODIFF
-      || XFASTINT (w->last_overlay_modified) < OVERLAY_MODIFF)
+  if (w->last_modified < MODIFF
+      || w->last_overlay_modified < OVERLAY_MODIFF)
     {
       /* Gap in the line?  */
       if (GPT < start || Z - GPT < end)
@@ -12790,9 +12790,9 @@
 	pt = marker_position (w->pointm);
 
       if ((w->current_matrix->buffer != XBUFFER (w->buffer)
-	   || pt != XINT (w->last_point))
+	   || pt != w->last_point)
 	  && check_point_in_composition (w->current_matrix->buffer,
-					 XINT (w->last_point),
+					 w->last_point,
 					 XBUFFER (w->buffer), pt))
 	b->clip_changed = 1;
     }
@@ -13014,9 +13014,9 @@
   if (!NILP (w->column_number_displayed)
       /* This alternative quickly identifies a common case
 	 where no change is needed.  */
-      && !(PT == XFASTINT (w->last_point)
-	   && XFASTINT (w->last_modified) >= MODIFF
-	   && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF)
+      && !(PT == w->last_point
+	   && w->last_modified >= MODIFF
+	   && w->last_overlay_modified >= OVERLAY_MODIFF)
       && (XFASTINT (w->column_number_displayed) != current_column ()))
     w->update_mode_line = 1;
 
@@ -13079,8 +13079,8 @@
     }
   else if (EQ (selected_window, minibuf_window)
 	   && (current_buffer->clip_changed
-	       || XFASTINT (w->last_modified) < MODIFF
-	       || XFASTINT (w->last_overlay_modified) < OVERLAY_MODIFF)
+	       || w->last_modified < MODIFF
+	       || w->last_overlay_modified < OVERLAY_MODIFF)
 	   && resize_mini_window (w, 0))
     {
       /* Resized active mini-window to fit the size of what it is
@@ -13145,8 +13145,8 @@
 	      || FETCH_BYTE (BYTEPOS (tlbufpos)) == '\n'))
 	/* Former continuation line has disappeared by becoming empty.  */
 	goto cancel;
-      else if (XFASTINT (w->last_modified) < MODIFF
-	       || XFASTINT (w->last_overlay_modified) < OVERLAY_MODIFF
+      else if (w->last_modified < MODIFF
+	       || w->last_overlay_modified < OVERLAY_MODIFF
 	       || MINI_WINDOW_P (w))
 	{
 	  /* We have to handle the case of continuation around a
@@ -13250,7 +13250,7 @@
 	    goto cancel;
 	}
       else if (/* Cursor position hasn't changed.  */
-	       PT == XFASTINT (w->last_point)
+	       PT == w->last_point
 	       /* Make sure the cursor was last displayed
 		  in this window.  Otherwise we have to reposition it.  */
 	       && 0 <= w->cursor.vpos
@@ -13666,10 +13666,8 @@
     {
       struct buffer *b = XBUFFER (w->buffer);
 
-      w->last_modified
-	= make_number (accurate_p ? BUF_MODIFF (b) : 0);
-      w->last_overlay_modified
-	= make_number (accurate_p ? BUF_OVERLAY_MODIFF (b) : 0);
+      w->last_modified = accurate_p ? BUF_MODIFF(b) : 0;
+      w->last_overlay_modified = accurate_p ? BUF_OVERLAY_MODIFF (b) : 0;
       w->last_had_star
 	= BUF_MODIFF (b) > BUF_SAVE_MODIFF (b);
 
@@ -13691,9 +13689,9 @@
 	  w->last_cursor_off_p = w->cursor_off_p;
 
 	  if (w == XWINDOW (selected_window))
-	    w->last_point = make_number (BUF_PT (b));
+	    w->last_point = BUF_PT (b);
 	  else
-	    w->last_point = make_number (XMARKER (w->pointm)->charpos);
+	    w->last_point = XMARKER (w->pointm)->charpos;
 	}
     }
 
@@ -14954,8 +14952,6 @@
 	   && !NILP (BVAR (current_buffer, mark_active)))
       && NILP (w->region_showing)
       && NILP (Vshow_trailing_whitespace)
-      /* Right after splitting windows, last_point may be nil.  */
-      && INTEGERP (w->last_point)
       /* This code is not used for mini-buffer for the sake of the case
 	 of redisplaying to replace an echo area message; since in
 	 that case the mini-buffer contents per se are usually
@@ -15013,7 +15009,7 @@
 	  int scroll_p = 0, must_scroll = 0;
 	  int last_y = window_text_bottom_y (w) - this_scroll_margin;
 
-	  if (PT > XFASTINT (w->last_point))
+	  if (PT > w->last_point)
 	    {
 	      /* Point has moved forward.  */
 	      while (MATRIX_ROW_END_CHARPOS (row) < PT
@@ -15048,7 +15044,7 @@
 		      && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row)))
 		scroll_p = 1;
 	    }
-	  else if (PT < XFASTINT (w->last_point))
+	  else if (PT < w->last_point)
 	    {
 	      /* Cursor has to be moved backward.  Note that PT >=
 		 CHARPOS (startp) because of the outer if-statement.  */
@@ -15394,8 +15390,8 @@
     = (!NILP (w->window_end_valid)
        && !current_buffer->clip_changed
        && !current_buffer->prevent_redisplay_optimizations_p
-       && XFASTINT (w->last_modified) >= MODIFF
-       && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF);
+       && w->last_modified >= MODIFF
+       && w->last_overlay_modified >= OVERLAY_MODIFF);
 
   /* Run the window-bottom-change-functions
      if it is possible that the text on the screen has changed
@@ -15417,8 +15413,8 @@
   buffer_unchanged_p
     = (!NILP (w->window_end_valid)
        && !current_buffer->clip_changed
-       && XFASTINT (w->last_modified) >= MODIFF
-       && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF);
+       && w->last_modified >= MODIFF
+       && w->last_overlay_modified >= OVERLAY_MODIFF);
 
   /* When windows_or_buffers_changed is non-zero, we can't rely on
      the window end being valid, so set it to nil there.  */
@@ -15443,9 +15439,9 @@
   if (!NILP (w->column_number_displayed)
       /* This alternative quickly identifies a common case
 	 where no change is needed.  */
-      && !(PT == XFASTINT (w->last_point)
-	   && XFASTINT (w->last_modified) >= MODIFF
-	   && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF)
+      && !(PT == w->last_point
+	   && w->last_modified >= MODIFF
+	   && w->last_overlay_modified >= OVERLAY_MODIFF)
       && (XFASTINT (w->column_number_displayed) != current_column ()))
     update_mode_line = 1;
 
@@ -15561,8 +15557,8 @@
 	  startp = run_window_scroll_functions (window, startp);
 	}
 
-      w->last_modified = make_number (0);
-      w->last_overlay_modified = make_number (0);
+      w->last_modified = 0;
+      w->last_overlay_modified = 0;
       if (CHARPOS (startp) < BEGV)
 	SET_TEXT_POS (startp, BEGV, BEGV_BYTE);
       else if (CHARPOS (startp) > ZV)
@@ -15687,8 +15683,8 @@
 	   && (CHARPOS (startp) < ZV
 	       /* Avoid starting at end of buffer.  */
 	       || CHARPOS (startp) == BEGV
-	       || (XFASTINT (w->last_modified) >= MODIFF
-		   && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF)))
+	       || (w->last_modified >= MODIFF
+		   && w->last_overlay_modified >= OVERLAY_MODIFF)))
     {
       int d1, d2, d3, d4, d5, d6;
 
@@ -15775,8 +15771,8 @@
 
  try_to_scroll:
 
-  w->last_modified = make_number (0);
-  w->last_overlay_modified = make_number (0);
+  w->last_modified = 0;
+  w->last_overlay_modified = 0;
 
   /* Redisplay the mode line.  Select the buffer properly for that.  */
   if (!update_mode_line)
@@ -17135,7 +17131,7 @@
     GIVE_UP (5);
 
   /* Another way to prevent redisplay optimizations.  */
-  if (XFASTINT (w->last_modified) == 0)
+  if (w->last_modified == 0)
     GIVE_UP (6);
 
   /* Verify that window is not hscrolled.  */
@@ -27412,8 +27408,8 @@
   b = XBUFFER (w->buffer);
   if (part == ON_TEXT
       && EQ (w->window_end_valid, w->buffer)
-      && XFASTINT (w->last_modified) == BUF_MODIFF (b)
-      && XFASTINT (w->last_overlay_modified) == BUF_OVERLAY_MODIFF (b))
+      && w->last_modified == BUF_MODIFF (b)
+      && w->last_overlay_modified == BUF_OVERLAY_MODIFF (b))
     {
       int hpos, vpos, dx, dy, area = LAST_AREA;
       ptrdiff_t pos;


             reply	other threads:[~2012-06-25  8:56 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-25  8:56 Dmitry Antipov [this message]
2012-06-25 14:22 ` 'struct window' cleanup #2 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
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

  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=4FE827B6.6020306@yandex.ru \
    --to=dmantipov@yandex.ru \
    --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).