kaar3k
kaar3k

Reputation: 994

CGContextSaveGState performance

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

Answers (1)

Peter Hosey
Peter Hosey

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

Related Questions