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: a07f3367d7,3a6a9f1d654285ba X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsfeed.velia.net!noris.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Tue, 01 Sep 2009 16:36:17 +0200 From: Georg Bauhaus User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada Shootout program for K-Nucleotide (patches) References: <4a743343$0$32674$9b4e6d93@newsspool2.arcor-online.net> <0c18b36c-7af0-454c-8208-9b0416111a1f@w41g2000yqb.googlegroups.com> <4a758ce2$0$31338$9b4e6d93@newsspool4.arcor-online.net> <4a967b33$0$32671$9b4e6d93@newsspool2.arcor-online.net> <4a9d06b9$0$30234$9b4e6d93@newsspool1.arcor-online.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4a9d3162$0$30222$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 01 Sep 2009 16:36:18 CEST NNTP-Posting-Host: 2a7b2510.newsspool1.arcor-online.net X-Trace: DXC=?Uf Ole-Hjalmar Kristensen schrieb: >>>>>> "GB" == Georg Bauhaus writes: > > I think the problem is not the explicit copy which happens when we hit > the end of the buffer (easily verified, just increase the buffer size > 10 times, the copying will happen 1/10 of the time, but execution time > stays the same), but the implicit copy which seems to happen in the statement > return In_Buf(Start..I-1); I do not know if this copy is unavoidable, > or if the compiler could have optimized it away. WRT return In_Buf(Start..I-1), there seems to be a way to have the bounds shift towards 1 .. Result'Length without copying: with Ada.Text_IO; procedure Bnds is function S return String is begin return String'(10 .. 20 => '*'); end S; X : constant String := S; begin Ada.Text_IO.Put_Line(Positive'Image(X'First)); declare subtype XString is String(1 .. X'Length); Z : XString; pragma Import (Ada, Z); for Z'Address use X'Address; begin Ada.Text_IO.Put_Line(Positive'Image(Z'First)); end; end Bnds; Is this "phantom sliding" accidental or can it be relied upon? > The idea of using a storage pool is an interesting one, since it could > allow you to avoid copying when you want to return a string from a > function. But how would you overlay the string on top of the read > buffer? An Ada string is not a C string, you would need to put the > descriptor somewhere as well. I'll reread "Accessing Memory as a String", http://adapower.com/adapower1/lang/accessmem.html Maybe this leads somewhere regarding this question.