• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How best to extract digits from a string?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How best to extract digits from a string?


  • Subject: Re: How best to extract digits from a string?
  • From: Jed Verity <email@hidden>
  • Date: Thu, 26 Apr 2001 09:36:25 -0700

After running some simple benchmark tests, I found the concatenation method
to be dramatically faster for strings. For example:

--Concat Test:
set str to ""
repeat 5000 times
set str to str & "a"
end

--List Test
set str to {}
repeat 5000 times
set end of str to "a"
end
set applescript's text item delimiters to ""
str as string



On 4/26/01 8:31 AM, you wanted me to know this:

> On 4/26/01 3:14 AM, "Bill Cheeseman" <email@hidden> wrote:
>
>> on 4/25/01 11:46 PM, Paul Berkowitz at email@hidden wrote:
>>
>>> repeat with i from 1 to (count input)
>>> set char to character i of input
>>> if char is in digits then set end of output to char
>>> end repeat
>>
>> Do you say this is better than concatenating strings on the basis of testing
>> or theory?
>>
>> I understand that the "end of" syntax was provided as a speedier way of
>> building lists than concatenating them. (The old AppleScript 1.1 release
>> notes regarding the differences between linked lists and vector lists make
>> fascinating if difficult reading.)
>>
>> But I don't know anything about how strings are implemented under the hood,
>> and I wonder whether the list approach in general is faster or slower than
>> concatenating strings.
>>
> I've seen really dramatic differences with enormous text operations. But it
> was far too long ago in scripts I only dimly recall to be able to check now
> as to whether there were other circumstances which caused these differences.
> So this counts more as "folk memory" (i.e. could be hogwash) rather than
> rigorous testing. I'll do some of the latter at the next real opportunity.
> Perhaps others will chime in here.


~)~)~)~)~)~)~)~)~)~)~)~)~)
Jed Verity


  • Follow-Ups:
    • Re: How best to extract digits from a string?
      • From: Paul Berkowitz <email@hidden>
References: 
 >Re: How best to extract digits from a string? (From: Paul Berkowitz <email@hidden>)

  • Prev by Date: Re: Screen Blanking-duh...
  • Next by Date: RE: Screen Blanking-duh...
  • Previous by thread: Re: How best to extract digits from a string?
  • Next by thread: Re: How best to extract digits from a string?
  • Index(es):
    • Date
    • Thread