bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#35062: [PATCH v3 2/3] constify a bit of xterm.c


From: Konstantin Kharlamov
Subject: bug#35062: [PATCH v3 2/3] constify a bit of xterm.c
Date: Sun, 7 Apr 2019 05:13:30 +0300

* src/xterm.c (x_cr_draw_image, x_update_begin,
x_clear_under_internal_border, x_draw_fringe_bitmap,
x_set_glyph_string_clipping, x_draw_glyph_string_background,
x_draw_composite_glyph_string_foreground, x_send_scroll_bar_event): make
code easier to follow by making explicit that some variables are
immutable. (Bug#35062)
---
v3: mention functions changed in commit messages, mention the bug
number, and don't mention that it fixes a warning since intention  of
changes is clear either way.

 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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]