From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e6c9800e35ccfeee X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: GNAT: Performance of String functions Date: 1997/07/19 Message-ID: #1/1 X-Deja-AN: 257811992 References: <33CF3908.3DF62EEE@ericsson.com> <33D11806.6C59@online.no> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-07-19T00:00:00+00:00 List-Id: 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 (818) 985-1271