#define CC_PROPERTY_PASS_BY_REF(varType, varName, funName)protected: varType varName;public: virtual varType get##funName(void);
why the “get” function changed to this one? it’s less efficient than “const varType& get##funName(void);”
why?why?
#define CC_PROPERTY_PASS_BY_REF(varType, varName, funName)protected: varType varName;public: virtual varType get##funName(void);
why the “get” function changed to this one? it’s less efficient than “const varType& get##funName(void);”
why?why?
Because it is not safe.
When subclass override the function, it will return a reference for a temple variable.
I am not sure if it is correct to change it, for safety or for performance.
the return value must be a member variable, at least in the engine it will work fine. what the unsafe situation?
but, the “getPosition()” of CCNode is a key method in a game loop, and many other methods are also executed every frame, the performance should be down a little bit, it’s not worth.