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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5cb36983754f64da X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-02-17 01:14:19 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!nnx.oleane.net!oleane!news-FFM2.ecrc.net!news.iks-jena.de!not-for-mail From: Lutz Donnerhacke Newsgroups: comp.lang.ada Subject: Re: No call for Ada (was Re: Announcing new scripting/prototyping language) Date: Tue, 17 Feb 2004 09:14:18 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: References: <20040206174017.7E84F4C4114@lovelace.ada-france.org> <54759e7e.0402071124.322ea376@posting.google.com> <2460735.u7KiuvdgQP@linux1.krischik.com> <54759e7e.0402081525.50c7adae@posting.google.com> <54759e7e.0402091826.2847e0c@posting.google.com> <54759e7e.0402101819.95cec1d@posting.google.com> NNTP-Posting-Host: taranis.iks-jena.de X-Trace: branwen.iks-jena.de 1077009258 18378 217.17.192.37 (17 Feb 2004 09:14:18 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Tue, 17 Feb 2004 09:14:18 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:5628 Date: 2004-02-17T09:14:18+00:00 List-Id: * Robert I. Eachus wrote: > with Ada.Command_Line; use Ada.Command_Line; > with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; > with Ada.Strings.Fixed; use Ada.Strings; > with Ada.Text_Io; use Ada.Text_Io; > procedure Strcat is > N: Integer; > Hello : String := "hello" & Ascii.Lf; > begin > if Argument_Count < 1 > then N := 10_000; > else N := Integer'Value(Argument(1)); > end if; > declare > Buffer : Unbounded_String := N*Hello; > begin > Put_Line(Ada.Strings.Fixed.Trim > (Integer'Image(Length(Buffer)),Left)); > end; > end Strcat; > > This results in about a 100x speed up. Is this the right way to write > it and the code they had wrong? In one sense, that probably is true. > But if I use Bounded_String, the version on the website is slightly > faster, and both versions fall midway between the fast and slow > Unbounded versions. (A version that just uses String is actually faster > than the Unbounded String version. However, I think that version is a > bit of a cheat. ;-) I do not see any cheat in: with Ada.Command_Line; use Ada.Command_Line; with Ada.Strings.Fixed; use Ada.Strings, Ada.Strings.Fixed; with Ada.Text_IO; use Ada.Text_IO; procedure Strcat is N: Natural; Hello : String := "hello" & ASCII.LF; begin if Argument_Count < 1 then N := 10_000; else N := Natural'Value(Argument(1)); end if; declare Buffer : String := N*Hello; begin Put_Line(Trim(Natural'Image(Buffer'Length), Left)); end; end Strcat;