emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r111395: Simplify via eabs.


From: Paul Eggert
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111395: Simplify via eabs.
Date: Tue, 01 Jan 2013 23:57:00 -0800
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111395
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Tue 2013-01-01 23:57:00 -0800
message:
  Simplify via eabs.
  
  * dired.c (file_name_completion):
  * doc.c (get_doc_string):
  * floatfns.c (round2):
  * font.c (font_score, font_delete_unmatched):
  * fringe.c (compute_fringe_widths):
  * lread.c (read_list):
  * minibuf.c (Ftry_completion):
  * term.c (tty_ins_del_lines):
  * xterm.c (x_draw_image_foreground, x_draw_image_foreground_1):
  Use eabs (x) rather than open-coding it as (x < 0 ? -x : x).
modified:
  src/ChangeLog
  src/dired.c
  src/doc.c
  src/floatfns.c
  src/font.c
  src/fringe.c
  src/lread.c
  src/minibuf.c
  src/term.c
  src/xterm.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-12-31 16:09:00 +0000
+++ b/src/ChangeLog     2013-01-02 07:57:00 +0000
@@ -1,3 +1,17 @@
+2013-01-02  Paul Eggert  <address@hidden>
+
+       Simplify via eabs.
+       * dired.c (file_name_completion):
+       * doc.c (get_doc_string):
+       * floatfns.c (round2):
+       * font.c (font_score, font_delete_unmatched):
+       * fringe.c (compute_fringe_widths):
+       * lread.c (read_list):
+       * minibuf.c (Ftry_completion):
+       * term.c (tty_ins_del_lines):
+       * xterm.c (x_draw_image_foreground, x_draw_image_foreground_1):
+       Use eabs (x) rather than open-coding it as (x < 0 ? -x : x).
+
 2012-12-31  Eli Zaretskii  <address@hidden>
 
        * w32.c (unsetenv): Set up the string passed to _putenv

=== modified file 'src/dired.c'
--- a/src/dired.c       2012-12-14 18:59:00 +0000
+++ b/src/dired.c       2013-01-02 07:57:00 +0000
@@ -671,10 +671,7 @@
                                name, zero,
                                make_number (compare),
                                completion_ignore_case ? Qt : Qnil);
-         ptrdiff_t matchsize
-           = (EQ (cmp, Qt)     ? compare
-              : XINT (cmp) < 0 ? - XINT (cmp) - 1
-              :                  XINT (cmp) - 1);
+         ptrdiff_t matchsize = EQ (cmp, Qt) ? compare : eabs (XINT (cmp)) - 1;
 
          if (completion_ignore_case)
            {

=== modified file 'src/doc.c'
--- a/src/doc.c 2012-11-30 17:27:41 +0000
+++ b/src/doc.c 2013-01-02 07:57:00 +0000
@@ -83,24 +83,23 @@
   ptrdiff_t minsize;
   int offset;
   EMACS_INT position;
-  Lisp_Object file, tem;
+  Lisp_Object file, tem, pos;
   USE_SAFE_ALLOCA;
 
   if (INTEGERP (filepos))
     {
       file = Vdoc_file_name;
-      position = XINT (filepos);
+      pos = filepos;
     }
   else if (CONSP (filepos))
     {
       file = XCAR (filepos);
-      position = XINT (XCDR (filepos));
+      pos = XCDR (filepos);
     }
   else
     return Qnil;
 
-  if (position < 0)
-    position = - position;
+  position = eabs (XINT (pos));
 
   if (!STRINGP (Vdoc_directory))
     return Qnil;

=== modified file 'src/floatfns.c'
--- a/src/floatfns.c    2012-09-23 08:44:20 +0000
+++ b/src/floatfns.c    2013-01-02 07:57:00 +0000
@@ -399,8 +399,8 @@
      odd.  */
   EMACS_INT q = i1 / i2;
   EMACS_INT r = i1 % i2;
-  EMACS_INT abs_r = r < 0 ? -r : r;
-  EMACS_INT abs_r1 = (i2 < 0 ? -i2 : i2) - abs_r;
+  EMACS_INT abs_r = eabs (r);
+  EMACS_INT abs_r1 = eabs (i2) - abs_r;
   return q + (abs_r + (q & 1) <= abs_r1 ? 0 : (i2 ^ r) < 0 ? -1 : 1);
 }
 

=== modified file 'src/font.c'
--- a/src/font.c        2012-11-18 11:29:06 +0000
+++ b/src/font.c        2013-01-02 07:57:00 +0000
@@ -2101,9 +2101,7 @@
       {
        EMACS_INT diff = ((XINT (AREF (entity, i)) >> 8)
                          - (XINT (spec_prop[i]) >> 8));
-       if (diff < 0)
-         diff = - diff;
-       score |= min (diff, 127) << sort_shift_bits[i];
+       score |= min (eabs (diff), 127) << sort_shift_bits[i];
       }
 
   /* Score the size.  Maximum difference is 127.  */
@@ -2118,10 +2116,7 @@
 
       if (CONSP (Vface_font_rescale_alist))
        pixel_size *= font_rescale_ratio (entity);
-      diff = pixel_size - XINT (AREF (entity, FONT_SIZE_INDEX));
-      if (diff < 0)
-       diff = - diff;
-      diff <<= 1;
+      diff = eabs (pixel_size - XINT (AREF (entity, FONT_SIZE_INDEX))) << 1;
       if (! NILP (spec_prop[FONT_DPI_INDEX])
          && ! EQ (spec_prop[FONT_DPI_INDEX], AREF (entity, FONT_DPI_INDEX)))
        diff |= 1;
@@ -2671,9 +2666,7 @@
        {
          int diff = XINT (AREF (entity, FONT_SIZE_INDEX)) - size;
 
-         if (diff != 0
-             && (diff < 0 ? -diff > FONT_PIXEL_SIZE_QUANTUM
-                 : diff > FONT_PIXEL_SIZE_QUANTUM))
+         if (eabs (diff) > FONT_PIXEL_SIZE_QUANTUM)
            prop = FONT_SPEC_MAX;
        }
       if (prop < FONT_SPEC_MAX

=== modified file 'src/fringe.c'
--- a/src/fringe.c      2012-12-11 06:08:53 +0000
+++ b/src/fringe.c      2013-01-02 07:57:00 +0000
@@ -1360,8 +1360,8 @@
 
   if (left_fringe_width || right_fringe_width)
     {
-      int left_wid = left_fringe_width >= 0 ? left_fringe_width : 
-left_fringe_width;
-      int right_wid = right_fringe_width >= 0 ? right_fringe_width : 
-right_fringe_width;
+      int left_wid = eabs (left_fringe_width);
+      int right_wid = eabs (right_fringe_width);
       int conf_wid = left_wid + right_wid;
       int font_wid = FRAME_COLUMN_WIDTH (f);
       int cols = (left_wid + right_wid + font_wid-1) / font_wid;

=== modified file 'src/lread.c'
--- a/src/lread.c       2012-12-10 02:00:42 +0000
+++ b/src/lread.c       2013-01-02 07:57:00 +0000
@@ -3569,9 +3569,8 @@
                         doc string, caller must make it
                         multibyte.  */
 
-                     EMACS_INT pos = XINT (XCDR (val));
                      /* Position is negative for user variables.  */
-                     if (pos < 0) pos = -pos;
+                     EMACS_INT pos = eabs (XINT (XCDR (val)));
                      if (pos >= saved_doc_string_position
                          && pos < (saved_doc_string_position
                                    + saved_doc_string_length))

=== modified file 'src/minibuf.c'
--- a/src/minibuf.c     2012-10-31 10:02:51 +0000
+++ b/src/minibuf.c     2013-01-02 07:57:00 +0000
@@ -1398,12 +1398,7 @@
                                      eltstring, zero,
                                      make_number (compare),
                                      completion_ignore_case ? Qt : Qnil);
-             if (EQ (tem, Qt))
-               matchsize = compare;
-             else if (XINT (tem) < 0)
-               matchsize = - XINT (tem) - 1;
-             else
-               matchsize = XINT (tem) - 1;
+             matchsize = EQ (tem, Qt) ? compare : eabs (XINT (tem)) - 1;
 
              if (completion_ignore_case)
                {

=== modified file 'src/term.c'
--- a/src/term.c        2012-12-04 15:15:30 +0000
+++ b/src/term.c        2013-01-02 07:57:00 +0000
@@ -953,8 +953,8 @@
   const char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line;
   const char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll;
 
-  register int i = n > 0 ? n : -n;
-  register char *buf;
+  int i = eabs (n);
+  char *buf;
 
   /* If the lines below the insertion are being pushed
      into the end of the window, this is the same as clearing;

=== modified file 'src/xterm.c'
--- a/src/xterm.c       2012-12-12 15:33:30 +0000
+++ b/src/xterm.c       2013-01-02 07:57:00 +0000
@@ -2236,8 +2236,7 @@
             nothing here for mouse-face.  */
          if (s->hl == DRAW_CURSOR)
            {
-             int relief = s->img->relief;
-             if (relief < 0) relief = -relief;
+             int relief = eabs (s->img->relief);
              XDrawRectangle (s->display, s->window, s->gc,
                              x - relief, y - relief,
                              s->slice.width + relief*2 - 1,
@@ -2368,8 +2367,7 @@
             nothing here for mouse-face.  */
          if (s->hl == DRAW_CURSOR)
            {
-             int r = s->img->relief;
-             if (r < 0) r = -r;
+             int r = eabs (s->img->relief);
              XDrawRectangle (s->display, s->window, s->gc, x - r, y - r,
                              s->slice.width + r*2 - 1,
                              s->slice.height + r*2 - 1);


reply via email to

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