unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Konstantin Kharlamov <Hi-Angel@yandex.ru>
To: 35062@debbugs.gnu.org
Subject: bug#35062: [PATCH 2/4] constify a bit of xterm.c
Date: Mon,  1 Apr 2019 01:37:40 +0300	[thread overview]
Message-ID: <20190331223742.1351-3-Hi-Angel@yandex.ru> (raw)
In-Reply-To: <20190331223742.1351-1-Hi-Angel@yandex.ru>

* src/xterm.c: make code easier to follow by making explicit that some
variables are immutable
---
 src/xterm.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index e8f1e576a38..8354ce00700 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -495,9 +495,9 @@ x_cr_draw_image (struct frame *f, GC gc, cairo_surface_t *image,
       cairo_fill_preserve (cr);
     }
 
-  int orig_image_width = cairo_image_surface_get_width (image);
+  const int orig_image_width = cairo_image_surface_get_width (image);
   if (image_width == 0) image_width = orig_image_width;
-  int orig_image_height = cairo_image_surface_get_height (image);
+  const int orig_image_height = cairo_image_surface_get_height (image);
   if (image_height == 0) image_height = orig_image_height;
 
   cairo_pattern_t *pattern = cairo_pattern_create_for_surface (image);
@@ -1006,7 +1006,7 @@ x_update_begin (struct frame *f)
       if (FRAME_GTK_WIDGET (f))
         {
           GdkWindow *w = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
-	  int scale = xg_get_scale (f);
+	  const int scale = xg_get_scale (f);
 	  width = scale * gdk_window_get_width (w);
 	  height = scale * gdk_window_get_height (w);
         }
@@ -1300,15 +1300,15 @@ x_clear_under_internal_border (struct frame *f)
 {
   if (FRAME_INTERNAL_BORDER_WIDTH (f) > 0)
     {
-      int border = FRAME_INTERNAL_BORDER_WIDTH (f);
-      int width = FRAME_PIXEL_WIDTH (f);
-      int height = FRAME_PIXEL_HEIGHT (f);
+      const int border = FRAME_INTERNAL_BORDER_WIDTH (f);
+      const int width = FRAME_PIXEL_WIDTH (f);
+      const int height = FRAME_PIXEL_HEIGHT (f);
 #ifdef USE_GTK
-      int margin = 0;
+      const int margin = 0;
 #else
-      int margin = FRAME_TOP_MARGIN_HEIGHT (f);
+      const int margin = FRAME_TOP_MARGIN_HEIGHT (f);
 #endif
-      int face_id =
+      const int face_id =
 	!NILP (Vface_remapping_alist)
 	? lookup_basic_face (NULL, f, INTERNAL_BORDER_FACE_ID)
 	: INTERNAL_BORDER_FACE_ID;
@@ -1455,7 +1455,7 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring
       Drawable drawable = FRAME_X_DRAWABLE (f);
       char *bits;
       Pixmap pixmap, clipmask = (Pixmap) 0;
-      int depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f));
+      const int depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f));
       XGCValues gcv;
 
       if (p->wd > 8)
@@ -1704,7 +1704,7 @@ static void
 x_set_glyph_string_clipping (struct glyph_string *s)
 {
   XRectangle *r = s->clip;
-  int n = get_glyph_string_clip_rects (s, r, 2);
+  const int n = get_glyph_string_clip_rects (s, r, 2);
 
   if (n > 0)
     x_set_clip_rectangles (s->f, s->gc, r, n);
@@ -1797,7 +1797,7 @@ x_draw_glyph_string_background (struct glyph_string *s, bool force_p)
      shouldn't be drawn in the first place.  */
   if (!s->background_filled_p)
     {
-      int box_line_width = max (s->face->box_line_width, 0);
+      const int box_line_width = max (s->face->box_line_width, 0);
 
       if (s->stippled_p)
 	{
@@ -1908,15 +1908,15 @@ x_draw_composite_glyph_string_foreground (struct glyph_string *s)
     }
   else if (! s->first_glyph->u.cmp.automatic)
     {
-      int y = s->ybase;
+      const int y = s->ybase;
 
       for (i = 0, j = s->cmp_from; i < s->nchars; i++, j++)
 	/* TAB in a composition means display glyphs with padding
 	   space on the left or right.  */
 	if (COMPOSITION_GLYPH (s->cmp, j) != '\t')
 	  {
-	    int xx = x + s->cmp->offsets[j * 2];
-	    int yy = y - s->cmp->offsets[j * 2 + 1];
+	    const int xx = x + s->cmp->offsets[j * 2];
+	    const int yy = y - s->cmp->offsets[j * 2 + 1];
 
 	    font->driver->draw (s, j, j + 1, xx, yy, false);
 	    if (s->face->overstrike)
@@ -5516,7 +5516,7 @@ x_send_scroll_bar_event (Lisp_Object window, enum scroll_bar_part part,
   struct frame *f = XFRAME (w->frame);
   intptr_t iw = (intptr_t) w;
   verify (INTPTR_WIDTH <= 64);
-  int sign_shift = INTPTR_WIDTH - 32;
+  const int sign_shift = INTPTR_WIDTH - 32;
 
   block_input ();
 
-- 
2.21.0






  parent reply	other threads:[~2019-03-31 22:37 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-31 22:36 bug#35062: Patches: trivial cleanups Konstantin Kharlamov
2019-03-31 22:37 ` bug#35062: [PATCH 0/4] Trivial code cleanups Konstantin Kharlamov
2019-03-31 22:37   ` bug#35062: [PATCH 1/4] Remove redundant comparison Konstantin Kharlamov
2019-03-31 22:37   ` Konstantin Kharlamov [this message]
2019-03-31 22:37   ` bug#35062: [PATCH 3/4] min_cols/rows is always 0, don't check for it Konstantin Kharlamov
2019-04-01 22:37     ` Noam Postavsky
2019-04-02  0:09       ` Konstantin Kharlamov
2019-04-02 14:46         ` Eli Zaretskii
2019-04-02 20:54           ` Konstantin Kharlamov
2019-04-03  4:45             ` Eli Zaretskii
2019-04-02  0:23       ` bug#35062: [PATCH v2] min_cols/rows is always 0, remove noop actions Konstantin Kharlamov
2019-04-05  7:05         ` Eli Zaretskii
2019-04-05 22:18           ` Konstantin Kharlamov
2019-04-06  7:09             ` Eli Zaretskii
2019-04-07  2:03               ` Konstantin Kharlamov
2019-04-07  2:45                 ` Eli Zaretskii
2019-04-06  7:25             ` Michael Albinus
2019-03-31 22:37   ` bug#35062: [PATCH 4/4] don't compare unsigned to less-than-zero Konstantin Kharlamov
2019-04-01  4:37   ` bug#35062: [PATCH 0/4] Trivial code cleanups Eli Zaretskii
2019-04-01 13:27     ` Robert Pluim
2019-04-01 13:35       ` Konstantin Kharlamov
2019-04-01 13:41         ` Konstantin Kharlamov
2019-04-01 13:43         ` Robert Pluim
2019-04-01 13:51           ` Konstantin Kharlamov
2019-04-01 14:34       ` Eli Zaretskii
2019-04-01 15:04         ` Robert Pluim
2019-04-01 17:37           ` Eli Zaretskii
2019-04-02 20:49 ` bug#35062: [PATCH] Remove redundant multiplication of ch and cw Konstantin Kharlamov
2019-04-05  7:16   ` Eli Zaretskii
2019-04-07  2:13 ` bug#35062: [PATCH v3 1/3] Remove redundant comparison Konstantin Kharlamov
2019-04-07  2:13   ` bug#35062: [PATCH v3 2/3] constify a bit of xterm.c Konstantin Kharlamov
2019-04-13  8:15     ` Eli Zaretskii
2019-04-13 11:30       ` Konstantin Kharlamov
2019-04-13 11:36         ` Eli Zaretskii
2019-04-20  0:31       ` Paul Eggert
2019-04-20  1:09         ` Konstantin Kharlamov
2019-04-20  1:17           ` Konstantin Kharlamov
2019-04-20  6:53           ` Eli Zaretskii
2019-04-20 10:31             ` Konstantin Kharlamov
2019-04-20 11:01               ` Eli Zaretskii
2019-04-20 11:23                 ` Konstantin Kharlamov
2019-04-20 11:25                   ` Konstantin Kharlamov
2019-04-20 11:47                     ` Konstantin Kharlamov
2019-04-20 11:58                       ` Konstantin Kharlamov
2019-04-20  6:28         ` Eli Zaretskii
2019-04-07  2:13   ` bug#35062: [PATCH v3 3/3] don't compare unsigned to less-than-zero Konstantin Kharlamov
2019-04-13  8:11     ` Eli Zaretskii
2019-04-13  8:06   ` bug#35062: [PATCH v3 1/3] Remove redundant comparison Eli Zaretskii
2019-04-13 18:19     ` Konstantin Kharlamov
2019-04-13 18:24       ` Eli Zaretskii
2019-04-13 18:28         ` Konstantin Kharlamov
2019-04-13 19:19           ` Eli Zaretskii
2019-04-15  3:38             ` Richard Stallman
2019-04-15  6:49               ` Konstantin Kharlamov
2019-04-15 14:32                 ` Eli Zaretskii
2019-04-15 15:01                   ` Konstantin Kharlamov
2019-04-15 15:21                     ` Eli Zaretskii
2019-04-15 17:03                       ` Konstantin Kharlamov
2019-04-15 17:16                         ` Eli Zaretskii
2019-04-15 17:29                           ` Konstantin Kharlamov
2019-04-15 18:21                             ` Eli Zaretskii
2019-04-15 18:14                 ` Richard Stallman
2019-04-15 18:39                   ` Eli Zaretskii
2019-04-15 14:25               ` Eli Zaretskii
2019-04-16 21:27                 ` Richard Stallman
2019-04-17  2:40                   ` Eli Zaretskii
2019-04-17 20:52                     ` Richard Stallman
2019-06-23 18:07 ` bug#35062: Patches: trivial cleanups Lars Ingebrigtsen
2019-06-23 18:34   ` Constantine Kharlamov

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=20190331223742.1351-3-Hi-Angel@yandex.ru \
    --to=hi-angel@yandex.ru \
    --cc=35062@debbugs.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).