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,386228a37afe967f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-21 06:35:18 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!syros.belnet.be!news.belnet.be!uni-erlangen.de!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Computer Language Shootout Date: Mon, 21 Jul 2003 15:39:20 +0200 Message-ID: References: <1ec946d1.0307150715.4ba69f85@posting.google.com> <3F149243.80304@attbi.com> <3F15930C.2070907@attbi.com> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1058794516 15059966 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:40554 Date: 2003-07-21T15:39:20+02:00 List-Id: On Mon, 21 Jul 2003 11:00:38 GMT, "Jeffrey Creem" wrote: >"Dmitry A. Kazakov" wrote in message >news:vp9nhv8ju4t5kjrvdtd3sp3qgt59nu31tt@4ax.com... > >stuff deleted > >> Get_Line (Line.all, Size); >> Length := Size; >> while Size = Line'Last loop >> declare >> Old_Line : String_Ptr := Line; >> begin >> Line := new String'(Old_Line.all & (1..Increment => ' ')); >> Free (Old_Line); >> end; >> Get_Line (Line (Length + 1..Line'Last), Size); >> Length := Length + Size; >> end loop; >> end Read_Line; >> >> used as: >> >> Line : String_Ptr := new String'(1..Increment => ' '); >> Length : Natural; >> begin is >> Read_Line (Line, Length); > >Note, this will probably be slower. I see this all the time in code and I >wish it would go away. There is no need >to pad the string with blank characters. Yes it makes looking at the string >in a debugger a little easier but if >this thing gets called in a loop it is going to be much slower than it >should due to all the temporary creation and copying. Agree: Line := new String (1..Old_Line'Length + Increment); Line (1..Old_Line'Length) := Old_Line.all; However, I would expect padding be implemented using sort of memset, which should be "instant" as compared with "new". Actually there could be another excuse: a corrupted "commit on access" memory policy in some OS. Which reminds me speculating upon actions. (:-)) >If someone really felt they had to put characters in the unused portion of a >string, I would expect that using something like @ >would be the better choice to help hunt down messed up string index >values.....But I would rather that the >unused portion of the string be left alone. --- Regards, Dmitry Kazakov www.dmitry-kazakov.de