Re: get alias from ~/path
Re: get alias from ~/path
- Subject: Re: get alias from ~/path
- From: Kai <email@hidden>
- Date: Sun, 02 Mar 2003 20:25:17 +0000
on Sun, 2 Mar 2003 09:27:57 +0000, John Delacour <email@hidden> wrote:
>
At 11:30 pm -0700 1/3/03, Donald Hall wrote:
>
>
>Thanks also to John Delacour for his suggestions. I decided to stay
>
>with 'characters' rather than 'text'. I was afraid that 'text' would
>
>depend on how the text item delimiters are set, but apparently not.
>
>Why would it be better?
>
>
Its faster, when that matters, and shorter.
- And the reason it's faster is that 'text' acts directly on a string, while
'characters' creates a list:
===============
set x to "text"
x's text 1 thru -1
--> "text"
x's characters 1 thru -1
--> {"t", "e", "x", "t"}
===============
In addition, for many purposes (including the creation of file paths), a
character list then needs to be coerced back to a string.
To give an idea of the speed bump possible, here's a rough comparison:
------ --------
string index:
length text = 1
------ --------
10 --> 2
20 --> 3
30 --> 4
40 --> 5
50 --> 6
100 --> 12
------ --------
The first column, 'string length', shows the number of characters in each
test string, while column 2 gives the time taken to analyse 'characters'
(including a list-to-string coercion) - compared to that taken to process
'text'.
The results are expressed as an index: (time taken to process 'text' = 1).
So, using 'text', extracting part of a 10-character string is likely to be
about twice as fast as using 'characters' - and so on...
If that's not sufficiently compelling a reason to use 'text', bear in mind
that current TIDs will affect the result of a 'characters' list-to-string
coercion - while 'text' will be unaffected:
===============
set {x, text item delimiters} to {"text", "*"}
set {c, t, text item delimiters} to [NO-BREAK]
{x's characters 1 thru -1 as string, x's text 1 thru -1, {""}}
{c, t}
--> {"t*e*x*t", "text"}
===============
--
Kai
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.