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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,64b29dfa2220a59f X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!news3.google.com!fu-berlin.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Reserve_Capacity for Unbounded_String? From: Georg Bauhaus In-Reply-To: <46A70064.8090407@obry.net> References: <1185134043.892012.217560@n2g2000hse.googlegroups.com> <1185203238.701948.307410@m37g2000prh.googlegroups.com> <46A5B0FE.3060008@obry.net> <46A69136.3010803@obry.net> <46A70064.8090407@obry.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Message-ID: <1185357317.24786.39.camel@kartoffel> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Date: Wed, 25 Jul 2007 11:55:17 +0200 Organization: Arcor NNTP-Posting-Date: 25 Jul 2007 11:54:50 CEST NNTP-Posting-Host: d5eb704f.newsspool1.arcor-online.net X-Trace: DXC=3^g0hmj<_GT=>bdbdS?M0Yic==]BZ:af^4Fo<]lROoRQFl8W>\BH3YRC7L==5KlGV\N[W On Wed, 2007-07-25 at 09:48 +0200, Pascal Obry wrote: > Randy Brukardt a =C3=A9crit : > > And now I've wasted far too much time on this worthless topic. >=20 > If you think so! GNAT has implemented that as in a real application the > code was running more than 10 times faster. If you think you have wasted > far too much time, no problem. I'm not a Janus/Ada customer anyway! In fact, there are many special string-related subprograms in GNAT that arguably demonstrate the influences of effective marketing on technical properties of compilers. E.g. there are variations of function Str_Concat_3 (S1, S2, S3 : String) return String; -- Concatenate three strings and return resulting string hidden in System.String_Ops_Concat_3 and used in algorithmically (!) optimizing two "&"s in the compiler. Likewise, "... use of & removed for efficiency reasons" in package body Ada.Strings.Fixed. (See also Ada.Strings.Unbounded.Aux.Get_String for the unbounded case.) Two conclusion seem to follow from this: 1) that GNAT authors agree with Randy when he says that you have to be careful with "&"-centric algorithms, but 2) that AdaCore has better salespeople because customers are more satisfied when the vendor has already done the "right" thing for them. ;-) Try this: procedure Strtest is S: constant String :=3D "A" & Argument(1) & "B"; -- occurences of "&" --> GNAT special case begin Text_IO.put_line(S); end Strtest; Then, using GNAT, you get $ nm strtest.o ... 00000019 T _ada_strtest ... U system__string_ops_concat_3__str_concat_3 <-- $