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: 103376,4fbd260da735f6f4 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: Copying string slices before calling subroutines? Date: Fri, 04 May 2007 11:44:14 +0200 Organization: Jacob's private Usenet server Message-ID: References: <0hj5339mjmond132qhbn2o01unurs61lbj@4ax.com> <1178091967.392381.282510@o5g2000hsb.googlegroups.com> <5dv3wh6scrh1.2986pbvdw8y2$.dlg@40tude.net> NNTP-Posting-Host: taasingegade.news.jacob-sparre.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: jacob-sparre.dk 1178271856 30251 85.82.239.166 (4 May 2007 09:44:15 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 4 May 2007 09:44:16 +0000 (UTC) User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:z4pm2xjQ/c3GpOSdKAUL01dLSa0= Path: g2news1.google.com!news4.google.com!proxad.net!feed.ac-versailles.fr!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail Xref: g2news1.google.com comp.lang.ada:15505 Date: 2007-05-04T11:44:14+02:00 List-Id: Jacob Sparre Andersen wrote: > Dmitry A. Kazakov wrote: >> On Fri, 04 May 2007 08:53:59 +0200, Jacob Sparre Andersen wrote: >>> for Lines in 1 .. 10 loop >>> Last := Index (Source => Text (Text'First .. Last - 1), >> >> Did you check if GNAT did not copy the string slice before calling to >> Index? > > No. Do you have any suggestion for a way to check it. The > reference manual (section 6.2) seems to indicate that it is up to > the compiler to decide. I have found a strong indication that GNAT copies the whole string slice onto the stack before calling Index: It is limited how large files I can run my Tail program on, before I get a segmentation fault. The limit is roughly the allowed stack size on the system (and changes as I change the allowed stack size). This version appears to be as fast as the GNU Tail program. The only thing which worries me a bit is that I see roughly twice as many "minor pagefaults" with my own version as with the GNU version. Greetings, Jacob PS: I don't feel like cheating and looking at the GNU source code yet. -- "Then, after a second or so, nothing continued to happen."