comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Copying string slices before calling subroutines?
Date: Fri, 4 May 2007 14:46:11 +0200
Date: 2007-05-04T14:46:12+02:00	[thread overview]
Message-ID: <1sx3xkxshucv5$.1h3630hfmo53x$.dlg@40tude.net> (raw)
In-Reply-To: 4akrg4-mot.ln1@newserver.thecreems.com

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



  reply	other threads:[~2007-05-04 12:46 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-28  5:03 Reading and writing a big file in Ada (GNAT) on Windows XP Fionn Mac Cumhaill
2007-04-28  5:20 ` Gautier
2007-04-29 21:17   ` Fionn Mac Cumhaill
2007-04-28  5:25 ` tmoran
2007-04-28  6:56 ` Martin Krischik
2007-04-28 17:12   ` tmoran
2007-04-28 12:41 ` Jeffrey Creem
2007-04-29 21:35   ` Fionn Mac Cumhaill
2007-04-28 13:22 ` (see below)
2007-04-28 17:56 ` Simon Wright
2007-04-28 18:28   ` Jeffrey Creem
2007-04-29  7:20     ` Simon Wright
2007-04-29 21:44     ` Fionn Mac Cumhaill
2007-04-29 21:42   ` Fionn Mac Cumhaill
2007-04-30  0:48     ` Jeffrey R. Carter
2007-04-30  2:30       ` Fionn Mac Cumhaill
2007-04-30  4:21         ` tmoran
2007-04-28 19:12 ` Jeffrey R. Carter
2007-04-29 21:46   ` Fionn Mac Cumhaill
2007-05-01 14:10     ` Fionn Mac Cumhaill
2007-05-06 21:55     ` Quarc
2007-05-02  7:46 ` george
2007-05-03  6:31   ` Fionn Mac Cumhaill
2007-05-03 20:00     ` Simon Wright
2007-05-04  4:35       ` Jeffrey R. Carter
2007-05-04  4:45       ` Fionn Mac Cumhaill
2007-05-04  6:53       ` Alternative Index implementation? (Was: Reading and writing a big file in Ada (GNAT) on Windows XP) Jacob Sparre Andersen
2007-05-04  7:41         ` Dmitry A. Kazakov
2007-05-04  9:16           ` Copying string slices before calling subroutines? (Was: Alternative Index implementation?) Jacob Sparre Andersen
2007-05-04  9:44             ` Copying string slices before calling subroutines? Jacob Sparre Andersen
2007-05-04 10:14               ` Dmitry A. Kazakov
2007-05-04 12:07                 ` Jeffrey Creem
2007-05-04 12:46                   ` Dmitry A. Kazakov [this message]
2007-05-04 22:27                   ` Simon Wright
2007-05-05  7:33                     ` Jacob Sparre Andersen
2007-05-05  7:47                       ` Dmitry A. Kazakov
2007-05-05  7:41                     ` Dmitry A. Kazakov
2007-05-03 20:27     ` Reading and writing a big file in Ada (GNAT) on Windows XP Adam Beneschan
2007-05-03 23:01       ` Randy Brukardt
2007-05-04  0:28         ` Markus E Leypold
2007-05-05 16:26           ` Adam Beneschan
2007-05-05 17:27             ` Markus E Leypold
2007-05-15 23:03               ` Randy Brukardt
2007-05-04 20:04         ` Adam Beneschan
2007-05-05 16:36           ` tmoran
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox