comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@ni.net (Matthew Heaney)
Subject: Re: GNAT: Performance of String functions
Date: 1997/07/19
Date: 1997-07-19T00:00:00+00:00	[thread overview]
Message-ID: <mheaney-ya023680001907972339530001@news.ni.net> (raw)
In-Reply-To: 33D11806.6C59@online.no


In article <33D11806.6C59@online.no>, tarjei@online.no wrote:

>VAX Pascal passes strings by descriptors. The string pointed to by
>descriptor is of type counted string. A counted string has a maximum
>size, an actual size and the string itself.

That's all an Ada bounded string is: a maximum size (implicit in the size
of the array used to implement Bounded_String), and another component to
record the logical length of the string.

So I'm confused by your comment, because it sounds like they're very much
similar.

>This means that comparing Ada bounded strings and VAX Pascal strings
>compares two different ways of doing things.

This appears not the be the case; perhaps you can elaborate.

>Each time you change the
>size of an Ada bounded string there can be serious overhead.

What size do you mean: the physical length or the logical length.  I assume
logical length, because the physical size can't be changed.

But where's the "serious overhead" when changing the (logical) length of a
bounded string?  For example, if I have this (a hypothetical implementation
- I don't have GNAT source handy):

type Bounded_String is
   record
      Items : String (1 .. Max);
      Length : Natural := 0;
   end record;

and I do an append:

procedure Append (Bounded : in out Bounded_String; Item : in String) is
   Length : constant Natural := Bounded.Length + Item'Length;
   Items : String renames Bounded.Items;
begin
   if Length <= Max then

     Items (Bounded.Length + 1 .. Length) := Item;
     Bounded.Length := Length;

elsif ...

end Append;

Where's the overhead, exactly?

>The apparent overhead of bounded strings is an strong argument for
>providing a standard counted string package in Ada.

I think that that package is already included in Ada: it's called
Ada.Strings.Bounded.

Are you sure you aren't thinking of Unbounded_String?  That abstraction
definately is very likely to have greater overhead than any form of bounded
string.

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271




  reply	other threads:[~1997-07-19  0:00 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-07-18  0:00 GNAT: Performance of String functions Jakob Heinemann
1997-07-18  0:00 ` Robert Dewar
1997-07-19  0:00   ` Tarjei T. Jensen
1997-07-19  0:00     ` Matthew Heaney [this message]
1997-07-20  0:00     ` Tarjei T. Jensen
1997-07-20  0:00     ` Robert Dewar
1997-07-20  0:00       ` Tarjei T. Jensen
1997-07-20  0:00         ` Robert Dewar
1997-07-21  0:00           ` Tucker Taft
1997-07-21  0:00             ` Tarjei Jensen
1997-07-21  0:00               ` Matthew Heaney
1997-07-22  0:00               ` Robert Dewar
1997-07-22  0:00                 ` Tarjei Jensen
1997-07-22  0:00                   ` Robert Dewar
1997-07-22  0:00                   ` Larry Kilgallen
1997-07-22  0:00                     ` Tarjei T. Jensen
1997-07-23  0:00                       ` Larry Kilgallen
1997-07-23  0:00                       ` Robert Dewar
1997-07-23  0:00                         ` Tarjei Jensen
1997-07-23  0:00                           ` Samuel Mize
1997-07-23  0:00                             ` W. Wesley Groleau x4923
1997-07-24  0:00                             ` Robert A Duff
1997-07-24  0:00                           ` Mats Weber
1997-07-24  0:00                             ` Matthew Heaney
1997-07-24  0:00                             ` Tarjei Jensen
1997-07-24  0:00                               ` Matthew Heaney
1997-07-24  0:00                               ` Robert Dewar
1997-07-24  0:00                             ` Robert Dewar
1997-07-28  0:00                               ` Mats Weber
1997-07-28  0:00                                 ` Robert Dewar
1997-07-28  0:00                                   ` Robert Dewar
1997-07-28  0:00                                 ` Matthew Heaney
1997-07-29  0:00                                   ` Robert Dewar
1997-07-21  0:00             ` Robert Dewar
1997-07-22  0:00   ` Jakob Heinemann
1997-07-23  0:00     ` Robert Dewar
replies disabled

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