Re: Problems with speed & issues with coercion in OS 9.2.2 (App
Re: Problems with speed & issues with coercion in OS 9.2.2 (App
- Subject: Re: Problems with speed & issues with coercion in OS 9.2.2 (App
- From: Nigel Garvey <email@hidden>
- Date: Tue, 29 Jan 2002 01:52:53 +0000
Victor Yee wrote on Mon, 28 Jan 2002 16:17:25 -0500:
>
On Mon, 28 Jan 2002 10:25:11 -0500, Arthur J Knapp wrote,
>
>
> > return (string_or_alias as alias as string) ends with ":"
>
>
>
> Wow, that's great. :)
>
>
>
> If one were to speculate about things behind the scenes, it might be
>
> that AppleScript's "end of" syntax simply goes to the last item, where
>
> as a negative index might actually cause AS to go into "counting mode",
>
> ie: it begins a backwards traversal through the string until it comes
>
> to item -1. Obviously, it would get to item -1 rather quickly, but with
>
> the "end of" syntax, it wouldn't even begin a traversal in the first
>
> place.
>
>
Does that mean that "items 1 thru end" would be more efficient than "items 1
>
thru -1"?
"Items" by itself would be best here. ;-) But the forms "thru end" and
"thru -1" appear to take about the same time. They both simply identify
the end of the string. They don't try to identify the character there.
My own guess is that "ends with" gets its speed advantage from simply
comparing the ends of the strings, using the AppleScript's built-in code
for that function. "Character -1 =" has first to get character -1 of the
main string and *then* compare it with the other character - the same
basic process, but two AppleScript stages rather than one. As I said,
this is only a guess, but it seems plausible.
NG