From: Paul Eggert Date: Tue, 5 Apr 2011 05:14:06 +0000 (-0700) Subject: * xfont.c (xfont_open): Avoid unnecessary tests. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~394^2~18 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=625a3eb1e23bd4000230946eadb419d5c454845b;p=emacs.git * xfont.c (xfont_open): Avoid unnecessary tests. --- diff --git a/src/ChangeLog b/src/ChangeLog index 65488a6eedd..d489dcd58b3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,6 +1,7 @@ 2011-04-05 Paul Eggert * xfont.c (xfont_text_extents): Remove var that was set but not used. + (xfont_open): Avoid unnecessary tests. * composite.c (composition_gstring_put_cache): Use unsigned integer. diff --git a/src/xfont.c b/src/xfont.c index 8a3cacdd9f5..eaa1a3ea59b 100644 --- a/src/xfont.c +++ b/src/xfont.c @@ -844,22 +844,25 @@ xfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) font->average_width = XINT (val) / 10; if (font->average_width < 0) font->average_width = - font->average_width; - if (font->average_width == 0 - && encoding->ascii_compatible_p) + else { - int width = font->space_width, n = pcm != NULL; + if (font->average_width == 0 + && encoding->ascii_compatible_p) + { + int width = font->space_width, n = pcm != NULL; - for (char2b.byte2 = 33; char2b.byte2 <= 126; char2b.byte2++) - if ((pcm = xfont_get_pcm (xfont, &char2b)) != NULL) - width += pcm->width, n++; - if (n > 0) - font->average_width = width / n; + for (char2b.byte2 = 33; char2b.byte2 <= 126; char2b.byte2++) + if ((pcm = xfont_get_pcm (xfont, &char2b)) != NULL) + width += pcm->width, n++; + if (n > 0) + font->average_width = width / n; + } + if (font->average_width == 0) + /* No easy way other than this to get a reasonable + average_width. */ + font->average_width + = (xfont->min_bounds.width + xfont->max_bounds.width) / 2; } - if (font->average_width == 0) - /* No easy way other than this to get a reasonable - average_width. */ - font->average_width - = (xfont->min_bounds.width + xfont->max_bounds.width) / 2; } BLOCK_INPUT;