Reputation: 994
I am working on a app with image editing utilities where i use CoreGraphics,in few scenarios the images are huge which is fetched from the server.Does CGContextSaveGState using often has impact on the performance.
Upvotes: 0
Views: 278
Reputation: 96393
While rob mayoff's advice is very good and you should listen to him, I can spoil part of the reveal in this one case.
Yes. Saving and restoring gstates is very expensive. It's almost always cheaper to simply undo what you did.
That said, it's also usually much more readable code, so you should still measure it to see whether or not it's too expensive in your case. You might find that it's cheap enough that it's not worth the expense of rewriting the code to avoid it.
Upvotes: 3