RestKit/RestKit — pull request #2080 by carllindberg (2014-11-06 22:15:37+00:00)
Title: Always set unchanged values for newly-instantiated non-CoreData objects

The checking to determine if a property is unchanged (and to avoid calling the setter) is actually a little expensive, especially for non-CoreData situations where it's rarely needed anyways, since calling -valueForKey will allocate objects for scalar properties and the end result is usually just setting a normal property.

To speed things up, I added a property on RKMappingOperation which indicates if the destination object came from a data source or not, then use that in the data source methods in order to determine whether to check for changed values. CoreData will continue to use isTemporaryID for any managed objects, but for any other object originally created from a data source, we set values unconditionally. We only avoid it for objects provided externally (those are more likely to have KVO on them, etc.) Also, store the result from the data source once in the main method, instead of checking for every attribute. For some reason the profiling while investigating #2065 fingered that respondsToSelector: check, which seems wrong (the delegate check above was minimal), but... there is no good reason to check on every attribute, so may as well cache the response.

Timings before:
(Device) Mapping 5000 students with relationship mapping: 21.495014
(Simulator) Mapping 5000 students with relationship mapping: 3.057953

Timings after:
(Device) Mapping 5000 students with relationship mapping: 20.827214
(Simulator) Mapping 5000 students with relationship mapping: 2.909065