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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Introductory Presentations, especially aimed at C++ programmers! Date: Tue, 13 Dec 2016 17:02:44 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <1905815374.502825168.454102.laguest-archeia.com@nntp.aioe.org> <877f7b5llo.fsf@nightsong.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 14 Dec 2016 00:01:27 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="2de9d856f5d37b2b11d02225ec8c0d99"; logging-data="10391"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+lJllq/fBrDlZPxx/fQx5vrptnDVMtCjk=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 In-Reply-To: Cancel-Lock: sha1:llAfO5c8jveCzlekTBxsb4m9enM= Xref: news.eternal-september.org comp.lang.ada:32800 Date: 2016-12-13T17:02:44-07:00 List-Id: On 12/13/2016 03:52 PM, Robert A Duff wrote: > > It depends on whether you care about very long lines. > If so, you want to double the buffer size each time > (or similar). One can double the buffer size each time without making an explicit copy, as GNAT's version does. > If the line is a million characters, the GNAT version > does around 20 recursive calls, whereas the version below > does around 1000 recursive calls. True. But in my experience a fixed buffer of 1,000 won't involve any recursion for 99.9% of calls, and will rarely recurse more than once. Worrying about the efficiency of very rare situations, given the general inefficiency of Text_IO anyway, seems like a waste of time. > You can't do "return Buffer & Get_Line;" without some copying. > I'm willing to believe that GNAT does more copying than is > absolutely necessary. I didn't copy anything. How the compiler translates what I wrote is immaterial, and I presume it will do a better job of optimizing the return than I could. -- Jeff Carter "Apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, the fresh water system, and public health, what have the Romans ever done for us?" Monty Python's Life of Brian 80