AFNetworking/AFNetworking — pull request #172 by aidansteele (2012-01-12 03:24:31+00:00)
Title: (Potentially) improving AFImageCache performance 

Hiya,

I'll preface this by saying that I am not sure if this is a valid change to be making to AFNetworking. My hesitation stems from the fact that the code was not like this to begin with and surely I'm not the first person to have thought of this "improvement". :-)

With that out of the way; I've removed a level of indirection wherein the image _data_ is being cached by `AFImageCache` rather than the image objects themselves (`UIImage` or `NSImage`, whichever takes your fancy). I found that caching the image data meant having to re-render the image to a bitmap each time an image was pulled out of the cache and displayed. Caching the images themselves meant that they only needed to be "rendered" into a bitmap once.

This improvements performance quite substantially, especially on iOS devices. A quick test (loading an image 100 times) shows a tenfold speed improvement by caching the image objects rather than their backing data.

Is there something (obvious|subtle) that I am missing? Why is the code not already like this?