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 04:00:39 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!wn12feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!sccrnsc03.POSTED!not-for-mail From: "Jeffrey Creem" Newsgroups: comp.lang.ada References: <1ec946d1.0307150715.4ba69f85@posting.google.com> <3F149243.80304@attbi.com> <3F15930C.2070907@attbi.com> Subject: Re: Computer Language Shootout X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: NNTP-Posting-Host: 66.31.5.146 X-Complaints-To: abuse@comcast.net X-Trace: sccrnsc03 1058785238 66.31.5.146 (Mon, 21 Jul 2003 11:00:38 GMT) NNTP-Posting-Date: Mon, 21 Jul 2003 11:00:38 GMT Organization: Comcast Online Date: Mon, 21 Jul 2003 11:00:38 GMT Xref: archiver1.google.com comp.lang.ada:40544 Date: 2003-07-21T11:00:38+00:00 List-Id: "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. 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.