RestKit/RKValueTransformers — pull request #15 by carllindberg (2014-11-03 19:53:03+00:00)
Title: ...

A hotspot found while investigating https://github.com/RestKit/RestKit/issues/2065 . The RKValueTransformers code creates an NSMutableArray to hold any errors obtained during the transformation process, but usually there will not be any. So, avoid creating the NSMutableArray of errors until we actually get one. This gets called for every attribute mapped, and the creation was actually pretty expensive overall.

Also use +new to avoid the autorelease (it will be contained in a userInfo so no need to autorelease), and avoided creation of the error userInfo if the error parameter was NULL. The array instance being created at all was the imporant one though; most attributes will not have transformation errors.

Timings before:
(Device) Mapping 5000 students with relationship mapping: 24.087797
(Simulator) Mapping 5000 students with relationship mapping: 3.415050

and after:
(Device) Mapping 5000 students with relationship mapping: 22.884412
(Simulator) Mapping 5000 students with relationship mapping: 3.239746