Re: Convert first char to lower case
Re: Convert first char to lower case
- Subject: Re: Convert first char to lower case
- From: has <email@hidden>
- Date: Tue, 8 Jan 2002 11:21:54 +0000
Paul Berkowitz wrote:
>
On 1/7/02 6:28 PM, "Nigel Garvey" <email@hidden>
>
wrote:
>
>
> 'ASCII number' and 'ASCII character' can be quite slow if you have to use
>
> them a lot. In AppleScript, it's more convenient to look for the first
>
> character in an alphabetical string of the upper-case characters, and to
>
> replace it with the same-numbered character from a lower-case string.
>
>
Nigel,
>
>
Knowing you, you've probably tested this.
>
>
But is 'offset ' that much faster
>
than ASCII number? It's also an osax. Wouldn't it be quicker yet to use text
>
item delimiters, which are also case-sensitive, and much faster?
Heh. While the rest of us regularly sweat and slave to achieve even 80 or
90% optimisation in our code, Nigel can usually toss up that other 10% with
nary a second thought. So I'm very disappointed in him for not getting
this one. ;)
The tid-based lookup IS faster - I've written replacements to "ASCII
number" and "ASCII character" that use this method and, IIRC, the speed-up
is something like 3-4x and 10-20x respectively. It's not often you'll see
vanilla code outstrip an OSAX, but with such a simple function I imagine
the overhead of sending and receiving the necessary Apple Events becomes
relatively significant.
Of course, those numbers don't translate into such a huge speed boost for
most routines since ASCII conversion is usually only a small part of the
whole (and there's plenty of easier ways to sap performance in AS than
using the odd osax call;), but in cases where you need the best performance
possible it's worth doing. (I only didn't mention it cos I didn't want to
blind the new guy with too much science...)
Cheers,
has