> On 22 May 2015, at 3:02 am, Jens Alfke <j...@mooseyard.com> wrote:
> 
>> Now that I have a path forward and understand why things are what they are, 
>> this brings up the wonderful speed issue of "how much slower is property 
>> access vs ivar access”.
> 
> Yeah, I think we’ve had some vigorous debates about this topic in the past.


Anecdotally, with some coarse measurements to confirm it, I changed a bunch of 
code in -initWithCoder: to set ivars directly instead of using the property 
accessors (or -set<Foo>:). For a very large object graph - I’m talking hundreds 
of thousands of objects - the speed-up was dramatic. Dearchiving that large 
file went from 11 MINUTES to about 2 seconds.

Because -initWithCoder: is an init method, setting ivars directly is par for 
the course, and at that time there can’t be any KVO observations depending on 
the property accessors, so it’s fine. However, if you have autosynthesized all 
your properties, to be completely safe and future-proof, you probably shouldn’t 
be doing this, even though right now the ivar names are predictable. That means 
that performance could be an issue with autosynthesized properties.

—Graham



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to