(obj-c) Is it worth it to instantiate pointers outside of method blocks
I was curious if there is any performance gain by doing this...
MyClass *_myClassPointer;
- (void)scrollViewDidScroll
{
_myClassPointer = (Already allocated object from somewhere else)
// do some stuff with _myClassPointer
}
My thought process is that since a method like this gets called so often,
there might be a small performance gain by declaring the pointer to
MyClass outside of the method so that the method does not have to allocate
the memory for the pointer every time.
Can you agree with my thought process? Are the gains so minimal that the
cleaner code of just doing it all in the method block is worth more than
the tiny performance gain?
No comments:
Post a Comment