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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4fbd260da735f6f4 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news.glorb.com!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.de!newsfeed01.chello.at!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Copying string slices before calling subroutines? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <0hj5339mjmond132qhbn2o01unurs61lbj@4ax.com> <1178091967.392381.282510@o5g2000hsb.googlegroups.com> <5dv3wh6scrh1.2986pbvdw8y2$.dlg@40tude.net> <4oppvmc6anir.g0mz9mrahmdo.dlg@40tude.net> <4akrg4-mot.ln1@newserver.thecreems.com> Date: Fri, 4 May 2007 14:46:11 +0200 Message-ID: <1sx3xkxshucv5$.1h3630hfmo53x$.dlg@40tude.net> NNTP-Posting-Date: 04 May 2007 14:46:12 CEST NNTP-Posting-Host: 50e236aa.newsspool2.arcor-online.net X-Trace: DXC=gIo`_S4UiP4^8FBo0_81f>A9EHlD;3Yc24Fo<]lROoR18kF7enW;^6ZC`4IXm65S@:3>?fN[ja\h9cL: X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:15518 Date: 2007-05-04T14:46:12+02:00 List-Id: On Fri, 04 May 2007 08:07:59 -0400, Jeffrey Creem wrote: > Dmitry A. Kazakov wrote: >> On Fri, 04 May 2007 11:44:14 +0200, Jacob Sparre Andersen wrote: >> >>> 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: >> >> So, Index was innocent. > > I don't know that I'd say that... Though it might be innocent in this > case, a quick look at the source code (which then remaps index to a > common string search package) looks to me like there are other > opportunities where some versions of the Index call will make another > copy in cases when it need not and further this does not appear to match > the comments in the package. Devastating. I take my words back. > Hmm...I don't see the optimization for identity mappings anyplace... It looks that they call "optimization" copying Source into Mapped_Source with remapping. Probably they hoped that comparing Pattern with a remapping slice could translate into a processor-specific string comparison instruction. Anyway... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de