This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gfortran, committed] Avoid redundant call to mpz_cmp



While cleaning out my tree, I committed the appended patch under the obviously correct rule. We were comparing the same numbers twice, instead of saving the result from the first comparison. Built and tested on i686-pc-linux.


- Tobi

Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/ChangeLog,v
retrieving revision 1.78
diff -u -p -r1.78 ChangeLog
--- ChangeLog   21 Jun 2004 12:37:43 -0000      1.78
+++ ChangeLog   21 Jun 2004 17:15:41 -0000
@@ -1,3 +1,8 @@
+2004-06-21  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       * array.c (gfc_insert_constructor): Avoid redundant call to
+       mpz_comp. Add 2004 to copyright years.
+
 2004-06-21  Joseph S. Myers  <jsm@polyomino.org.uk>

        * trans.h (stmtblock_t): Change has_scope to unsigned int.
Index: array.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/array.c,v
retrieving revision 1.4
diff -u -p -r1.4 array.c
--- array.c     27 May 2004 12:35:11 -0000      1.4
+++ array.c     21 Jun 2004 17:15:41 -0000
@@ -1,5 +1,5 @@
 /* Array things
-   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
    Contributed by Andy Vaught

 This file is part of GCC.
@@ -605,6 +605,7 @@ gfc_insert_constructor (gfc_expr * base,
 {
   gfc_constructor *c, *pre;
   expr_t type;
+  int t;

type = base->expr_type;

@@ -617,12 +618,13 @@ gfc_insert_constructor (gfc_expr * base,
         {
           if (type == EXPR_ARRAY)
             {
-              if (mpz_cmp (c->n.offset, c1->n.offset) < 0)
+             t = mpz_cmp (c->n.offset, c1->n.offset);
+              if (t < 0)
                 {
                   pre = c;
                   c = c->next;
                 }
-              else if (mpz_cmp (c->n.offset, c1->n.offset) == 0)
+              else if (t == 0)
                 {
                   gfc_error ("duplicated initializer");
                   break;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]