From: Jacob Sparre Andersen <sparre@nbi.dk>
Subject: Re: Copying string slices before calling subroutines?
Date: Sat, 05 May 2007 09:33:26 +0200
Date: 2007-05-05T09:33:26+02:00 [thread overview]
Message-ID: <yge8xc3208p.fsf@hugsarin.dmusyd.edu> (raw)
In-Reply-To: m2odl02phu.fsf@mac.com
Simon Wright <simon.j.wright@mac.com> writes:
> Jeffrey Creem <jeff@thecreems.com> writes:
>> function Index
>> (Source : String;
>> Pattern : String;
>> Going : Direction := Forward;
>> Mapping : Maps.Character_Mapping := Maps.Identity) return Natural
>> is
>> Cur_Index : Natural;
>> Mapped_Source : String (Source'Range);
>
> There's the problem that I had (in my case Source'Length was >
> 2_000_000!) calling Index from one of my tasks.
>
> My reworking begins
[...]
> which calls Ada.Strings.Maps.Value rather more often than I suppose
> it could. But since the normal case is for the mapping to be the
> identity mapping the most useful optimisation would be to check for
> Identity and just compare directly.
Wouldn't the proper solution be to separate out Mapping =
Maps.Identity and Mapping /= Maps.Identity? Even though we can do
cool things with default values for arguments, it isn't always
efficient.
function Index
(Source : String;
Pattern : String;
Going : Direction := Forward) return Natural;
function Index
(Source : String;
Pattern : String;
Going : Direction := Forward;
Mapping : Maps.Character_Mapping) return Natural;
I can't see that there can be any cases, where existing code will work
differently with these two specifications instead of the existing
single specification.
We should also remember that for a compiler writer team, Mapping =
Maps.Identity may not be the normal case.
> Someone else was asking whether GNAT copies on the stack before the
> call -- I see no evidence of that.
Now that the implementation of Index has been pointed out to me, I
agree. I could just see that it happened at some point during the
call to Index.
Greetings,
Jacob
--
�For there are only two reasons why war is made against a
republic: The one, to become lord over her: the other, the
fear of being occupied by her.� -- Nicolo Machiavelli
next prev parent reply other threads:[~2007-05-05 7:33 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
2007-05-04 22:27 ` Simon Wright
2007-05-05 7:33 ` Jacob Sparre Andersen [this message]
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