re PR libfortran/31501 (libgfortran internal unit I/O performance issues)

2007-04-28  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/31501
	* io/list_read.c (next_char): Fix whitespace.
	* io/io.h: Remove prototypes and define macros for is_array_io,
	is_stream_io, and is_internal_unit.
	* io/unit.c (is_array_io), (is_internal_unit), (is_stream_io): Delete
	these functions.
	* io/transfer.c (read_sf): Change handling of internal_unit to make a
	single call to salloc_r and use memcpy to transfer the data.

From-SVN: r124266
This commit is contained in:
Jerry DeLisle 2007-04-28 23:23:35 +00:00
parent 8e1f21e9c6
commit d10fb73e91
5 changed files with 32 additions and 46 deletions

View file

@ -1,3 +1,14 @@
2007-04-28 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/31501
* io/list_read.c (next_char): Fix whitespace.
* io/io.h: Remove prototypes and define macros for is_array_io,
is_stream_io, and is_internal_unit.
* io/unit.c (is_array_io), (is_internal_unit), (is_stream_io): Delete
these functions.
* io/transfer.c (read_sf): Change handling of internal_unit to make a
single call to salloc_r and use memcpy to transfer the data.
2007-04-27 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/31532

View file

@ -80,6 +80,14 @@ stream;
#define sset(s, c, n) ((s)->set)(s, c, n)
/* Macros for testing what kinds of I/O we are doing. */
#define is_array_io(dtp) ((dtp)->internal_unit_desc)
#define is_internal_unit(dtp) ((dtp)->u.p.unit_is_internal)
#define is_stream_io(dtp) ((dtp)->u.p.current_unit->flags.access == ACCESS_STREAM)
/* The array_loop_spec contains the variables for the loops over index ranges
that are encountered. Since the variables can be negative, ssize_t
is used. */
@ -672,15 +680,6 @@ internal_proto(get_internal_unit);
extern void free_internal_unit (st_parameter_dt *);
internal_proto(free_internal_unit);
extern int is_internal_unit (st_parameter_dt *);
internal_proto(is_internal_unit);
extern int is_array_io (st_parameter_dt *);
internal_proto(is_array_io);
extern int is_stream_io (st_parameter_dt *);
internal_proto(is_stream_io);
extern gfc_unit *find_unit (int);
internal_proto(find_unit);

View file

@ -165,7 +165,7 @@ next_char (st_parameter_dt *dtp)
/* Handle the end-of-record and end-of-file conditions for
internal array unit. */
if (is_array_io(dtp))
if (is_array_io (dtp))
{
if (dtp->u.p.at_eof)
longjmp (*dtp->u.p.eof_jump, 1);
@ -201,9 +201,9 @@ next_char (st_parameter_dt *dtp)
if (is_stream_io (dtp))
dtp->u.p.current_unit->strm_pos++;
if (is_internal_unit(dtp))
if (is_internal_unit (dtp))
{
if (is_array_io(dtp))
if (is_array_io (dtp))
{
/* End of record is handled in the next pass through, above. The
check for NULL here is cautionary. */

View file

@ -164,18 +164,19 @@ read_sf (st_parameter_dt *dtp, int *length, int no_error)
return base;
}
if (is_internal_unit (dtp))
{
readlen = *length;
q = salloc_r (dtp->u.p.current_unit->s, &readlen);
memcpy (p, q, readlen);
goto done;
}
readlen = 1;
n = 0;
do
{
if (is_internal_unit (dtp))
{
/* readlen may be modified inside salloc_r if
is_internal_unit (dtp) is true. */
readlen = 1;
}
q = salloc_r (dtp->u.p.current_unit->s, &readlen);
if (q == NULL)
break;
@ -244,6 +245,8 @@ read_sf (st_parameter_dt *dtp, int *length, int no_error)
dtp->u.p.sf_seen_eor = 0;
}
while (n < *length);
done:
dtp->u.p.current_unit->bytes_left -= *length;
if ((dtp->common.flags & IOPARM_DT_HAS_SIZE) != 0)

View file

@ -476,33 +476,6 @@ get_unit (st_parameter_dt *dtp, int do_create)
}
/* is_internal_unit()-- Determine if the current unit is internal or not */
int
is_internal_unit (st_parameter_dt *dtp)
{
return dtp->u.p.unit_is_internal;
}
/* is_array_io ()-- Determine if the I/O is to/from an array */
int
is_array_io (st_parameter_dt *dtp)
{
return dtp->internal_unit_desc != NULL;
}
/* is_stream_io () -- Determine if I/O is access="stream" mode */
int
is_stream_io (st_parameter_dt *dtp)
{
return dtp->u.p.current_unit->flags.access == ACCESS_STREAM;
}
/*************************/
/* Initialize everything */