Re: sort descriptor optimization
Re: sort descriptor optimization
- Subject: Re: sort descriptor optimization
- From: Matt Neuburg <email@hidden>
- Date: Tue, 04 Jul 2006 15:00:15 -0700
- Thread-topic: sort descriptor optimization
On Tue, 4 Jul 2006 10:44:34 -0700, "Adam R. Maxwell" <email@hidden>
said:
>
>On Jul 2, 2006, at 16:53, Adam R. Maxwell wrote:
>
>> Hi all,
>>
>> We have an application that uses a custom NSSortDescriptor subclass
>> to handle nil values and empty strings differently from default.
>> Essentially, it looks like this:
>
>[...]
>
>> It looks like -[NSSortDescriptor compareObject:toObject:] does some
>> caching of key paths, or somehow bypasses valueForKeyPath:
>> altogether, but I can't figure out how to do this.
>>
>> If anyone's interested in a test app to play with Shark, I've
>> posted it at <http://homepage.mac.com/amaxwell> as kvcTest.zip.
>> With our sort descriptor subclass, I'm seeing times in the ~50
>> second range on a 1.33 G4; with NSSortDescriptor, times are ~8
>> seconds.
>
>Well, having received no advice on this matter, I ended up filing
>rdar://problem/4612866 against valueForKeyPath: and rdar://problem/
>4612871 against array sorting when using an NSSortDescriptor subclass.
But you're doing this in such an odd way. Why are you subclassing
NSSortDescriptor at all? NSSortDescriptor itself tells you how it wants you
to deal with this sort of situation; as it stands, it can be initialized
with a comparison method selector. So, for example, if your comparands are
NSStrings, you could implement a special comparator (via a category on
NSString) and use it in your NSSortDescriptor. Do you see the same sort of
slowdown using that architecture?
As for some of your comparands being nil values, the obvious suggestion is,
Don't Do That. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden