BlueWanderer
BlueWanderer

Reputation: 2691

Is it expensive to pass structs like CATransform3D by value?

In Cocoa or Cocoa Touch, structs are always(or maybe almost always?) passed by value, even not-so-small ones like CGAffineTransform and even larger ones like CATransform3D.

Just... why? The want to make sure that the original variable is not changed? Or are there any other reasons?

Would it be good to pass large structs by const pointer or const reference (like if I could make sure that the value would not be changed)?

Upvotes: 0

Views: 52

Answers (1)

matt
matt

Reputation: 535831

You could do it, obviously, if that's what you wanted to do; but rule number one is Don't Optimize Prematurely. If you can prove you're having a problem that passing a pointer will alleviate, fine, then optimize; but I'm betting you're not having any such problem. It would be better to think about something else.

Upvotes: 1

Related Questions