re PR libfortran/38199 (missed optimization: I/O performance)
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 15 Apr 2012 11:52:44 +0000 (11:52 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 15 Apr 2012 11:52:44 +0000 (11:52 +0000)
2012-04-15  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR libfortran/38199
PR libfortran/50673
* intrinsics/string_intriniscs_inc.c (string_len_trim):
Remove prototypes for string_len_trim and move to...
* libgfortran.h (string_len_trim): ... here and
(string_len_trim_char4): ...here.
* io/unit.c: For non-array internal arrays where we do reading,
adjust the record length to the last non-blank character.
* io/unix.c:  Fix typo.

From-SVN: r186466

libgfortran/ChangeLog
libgfortran/intrinsics/string_intrinsics_inc.c
libgfortran/io/unit.c
libgfortran/io/unix.c
libgfortran/libgfortran.h

index 15b9f94..302895b 100644 (file)
@@ -1,3 +1,15 @@
+2012-04-15  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR libfortran/38199
+       PR libfortran/50673
+       * intrinsics/string_intriniscs_inc.c (string_len_trim):
+       Remove prototypes for string_len_trim and move to...
+       * libgfortran.h (string_len_trim): ... here and
+       (string_len_trim_char4): ...here.
+       * io/unit.c: For non-array internal arrays where we do reading,
+       adjust the record length to the last non-blank character.
+       * io/unix.c:  Fix typo.
+
 2012-04-10  Michael Matz  <matz@suse.de>
 
        * m4/cshift0.m4 (cshift0_'rtype_code`): Guard use of modulo.
index b20483d..a1f86b5 100644 (file)
@@ -44,9 +44,6 @@ extern void concat_string (gfc_charlen_type, CHARTYPE *,
                           gfc_charlen_type, const CHARTYPE *);
 export_proto(concat_string);
 
-extern gfc_charlen_type string_len_trim (gfc_charlen_type, const CHARTYPE *);
-export_proto(string_len_trim);
-
 extern void adjustl (CHARTYPE *, gfc_charlen_type, const CHARTYPE *);
 export_proto(adjustl);
 
index d5029dc..6b68e14 100644 (file)
@@ -397,7 +397,7 @@ get_internal_unit (st_parameter_dt *dtp)
   __gthread_mutex_lock (&iunit->lock);
 
   iunit->recl = dtp->internal_unit_len;
-  
+
   /* For internal units we set the unit number to -1.
      Otherwise internal units can be mistaken for a pre-connected unit or
      some other file I/O unit.  */
@@ -415,6 +415,26 @@ get_internal_unit (st_parameter_dt *dtp)
 
       start_record *= iunit->recl;
     }
+  else
+    {
+      /* If we are not processing an array, adjust the unit record length not
+        to include trailing blanks for list-formatted reads.  */
+      if (dtp->u.p.mode == READING && dtp->format == NULL)
+       {
+         if (dtp->common.unit == 0)
+           {
+             dtp->internal_unit_len =
+               string_len_trim (dtp->internal_unit_len, dtp->internal_unit);
+             iunit->recl = dtp->internal_unit_len;
+           }
+         else
+           {
+             dtp->internal_unit_len =
+               string_len_trim_char4 (dtp->internal_unit_len, dtp->internal_unit);
+             iunit->recl = dtp->internal_unit_len;
+           }
+       }
+    }
 
   /* Set initial values for unit parameters.  */
   if (dtp->common.unit)
index 278decd..185936f 100644 (file)
@@ -736,7 +736,7 @@ mem_alloc_w4 (stream * strm, int * len)
 }
 
 
-/* Stream read function for character(kine=1) internal units.  */
+/* Stream read function for character(kind=1) internal units.  */
 
 static ssize_t
 mem_read (stream * s, void * buf, ssize_t nbytes)
index ea20e14..e7f5b71 100644 (file)
@@ -791,6 +791,13 @@ internal_proto(fstrcpy);
 extern gfc_charlen_type cf_strcpy (char *, gfc_charlen_type, const char *);
 internal_proto(cf_strcpy);
 
+extern gfc_charlen_type string_len_trim (gfc_charlen_type, const char *);
+export_proto(string_len_trim);
+
+extern gfc_charlen_type string_len_trim_char4 (gfc_charlen_type,
+                                              const gfc_char4_t *);
+export_proto(string_len_trim_char4);
+
 /* io/intrinsics.c */
 
 extern void flush_all_units (void);