TIDs, speed, (Unicode) text
TIDs, speed, (Unicode) text
- Subject: TIDs, speed, (Unicode) text
- From: jj <email@hidden>
- Date: Sat, 01 Oct 2005 23:46:01 +0200
- Thread-topic: TIDs, speed, (Unicode) text
Hi all!
I think someone mentioned somewhere something about speed, text item
delimiters, Panther and Tiger...
I just found an unknown thing for me, so I'll share it...
Step 1. Copy some text to the clipboard from your favorite place (ensure it
contains, for example, 900 "a" chars).
Step 2. Run this:
######################################
set x to the clipboard as Unicode text
chrono
set o to tid("a")
set x to x's text items
tid(o)
chrono
######################################
I used here Smile's "chrono" to measure execution speed, but you can use
your favorite tool, or just count milliseconds in your mind very fast. I
used also built-in "tid()" handler in Smile. You can add this one to your
script if you need it:
######################################
to tid(t)
set oldTids to applescript's text item delimiters
set applescript's text item delimiters to t
oldTids
end tid
######################################
Now run this:
######################################
set x to the clipboard as text
chrono
set o to tid("a")
set x to x's text items
tid(o)
chrono
######################################
The first one will drop here "0.8" secs, against "0.01" for the second one.
The other thing I discovered:
######################################
set x to the clipboard as Unicode text
set o to tid("a")
set x to x's text items
tid(o)
count x
######################################
(And now run the same thing using "as text" instead)
If you have both uppercase and lowercase "a" characters in your text, you
will find that "as Unicode text" will perform a case-insensitive match,
while "as text" will only find lowercase chars (case-sensitive).
The "as text" way will not accept a "ignoring case" instruction, while "as
Unicode text" will accept "considering case".
So, perhaps the one who noticed decreasing speed using TIDs in Tiger is now
really getting Unicode text as input from its source (?).
I found this working with HTML (and I don't need actually Unicode support),
so my advice for those in this game is using this code (for speed's sake):
######################################
set x to the clipboard as text
set o to tid("a")
set y to x's text items
tid("A")
set y's end to x's text items
tid(o)
######################################
jj
--
http://www.macscripter.net/
http://www.osaxen.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden