comp.lang.ada
 help / color / mirror / Atom feed
From: brh@poplar111.cray.com (Brian Hanson)
Subject: Re: Efficient io of arbitrary binary data.
Date: 1996/09/16
Date: 1996-09-16T00:00:00+00:00	[thread overview]
Message-ID: <BRH.96Sep16002020@poplar111.cray.com> (raw)
In-Reply-To: 1996Sep14.153426.1@eisner


Larry Kilgallen) writes:

   In article <3239B3B2.1AE4@cray.com>, "Brian R. Hanson" <brh@cray.com> writes:

   > I a puzzled.  The approaches which Ada seems to allow all require 
   > much more copying of data as I am not allowed to return a reference
   > to a slice of an array I can only return the slice itself.

   Presuming the concern is runtime efficiency rather than code inspection
   efficiency :-), whether you return a slice or a reference to a slice
   may be immaterial. A compiler with aggressive optimization may generate
   inline code for your whole "read" function, making the object code
   for the two methods equivalent.  When programming in Ada you have
   given the compiler more information than programming in C, so it has
   more opportunity to optimize.  Based on your return address, I would
   presume folks in your shop are big on optimizing compilers.

Actually, folks in our shop are big on optimizing c, c++ and fortran compilers.
My target platforms - sgi (our new parent) and sun (our workstation of 
choice prior to acquiring a parent) - use gnat.

is it really likely that 


	case compare_keys(current_string(buf1), current_string(buf2)) is
	  when smaller, the_same =>
		store_string(buf3, current_string(buf1));
		advance_string(buf1);
	  when larger =>
		store_string(buf3, current_string(buf2));
		advance_string(buf2);
	end case;

would really optimize the copying of the string slices away.

   package buffers is
     type buffer_type is private;
     procedure advance_string(buf: in out buffer_type);
     function current_string(buf: in buffer_type) return string;
     procedure store_string(buf: in out buffer_type, data: in string);
   private 
     type buffer_type is record 
       data: string(65536);
       start: positive;
       length: positive;
       -- other details omitted.
     end record;
   end buffers;

   package body buffers is
     -- details omitted.

     function current_string(buf: in buffer_type) return string is
     begin
	return buf.data(buf.start, buf.length);
     end;
   end buffers;

Brian Hanson
--
-- Brian Hanson
-- brh@cray.com




  reply	other threads:[~1996-09-16  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-13  0:00 Efficient io of arbitrary binary data Brian R. Hanson
1996-09-14  0:00 ` Larry Kilgallen
1996-09-16  0:00   ` Brian Hanson [this message]
1996-09-16  0:00     ` Robert A Duff
1996-09-16  0:00     ` Larry Kilgallen
1996-09-16  0:00     ` Stephen Leake
1996-09-14  0:00 ` Larry Kilgallen
1996-09-14  0:00   ` Robert Dewar
1996-09-16  0:00   ` Brian Hanson
1996-09-17  0:00   ` Ted Dennison
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox