Re: Concatenating records
Re: Concatenating records
- Subject: Re: Concatenating records
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 28 Jan 2003 07:47:52 -0800
On 1/28/03 4:20 AM, "Kai" <email@hidden> wrote:
>
on Mon, 27 Jan 2003 00:43:21 -0800, Paul Berkowitz <email@hidden>
>
wrote:
>
>
> If I'm building up a record by concatenating a new property (label and
>
> value) to it, one by one, until I reach perhaps 100 properties, will it be
>
> more efficient memory-wise if I concatenate the new property to the end:
>
>
>
> set theRecord to theRecord & {newProperty:"New"}
>
>
>
> than if I do it the other way around:
>
>
>
> set theRecord to {newProperty:"New"} & theRecord
>
>
>
> ?
>
>
I don't know if this will help, Paul - but I compared the speed of the two
>
methods OMM. There was a slight but discernible benefit from using the first
>
method (concatenating a record on the left with a new property on the
>
right).
>
<snip>
>
>
In all cases, the 'record & new property' method consistently outperformed
>
the 'new property & record' version. While the precise speed bump could vary
>
between tests, the average was about 4-5%.
>
>
Not the kind of lead, perhaps, to earn a standing ovation - but probably
>
significant enough over many records. (Certainly suggests that your
>
instincts, however lingering, are still to be trusted!) ;-)
Thanks a lot for checking this, Kai. The script seems quite memory-draining,
and will very occasionally time out somewhere (not certain yet if it's on a
particular line or note) when there are thousands of items to do, so
anything helps. I don't want to add to the burden by switching the order
around, so I've done it only in the one place where a previous record
property may be revised by a subsequent option, where I put that property on
the left. (In some cases, it won't exist yet, so does need to be
concatenated rather than merely set.) But I won't change all the other 99
properties or so. I'm building up this record so that I can 'make new object
with properties {record: here}' all at once, omitting default value
properties. The idea was that this should be more efficient than just
creating the object and then setting each property with a separate Apple
Event. It still seems to take a lot longer when lots of non-default
properties have to be written, even this way as a properties record. One
day, I'll check how much time it actually saves, but I'm sure it does save
something. Thanks a lot for your help.
--
Paul Berkowitz
_______________________________________________
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.