I am working on a C++ project with high performance requirements. The data between some classes is shared via structures. This means several classes have a reference to the same structures and use them. My question is:
Is the performance of this code:
void foo(&myStruct)
{
//...
int var = myStruct.varA; // access struct by reference
//...
}
better or worse than this code?
class.h
int* temp; //member variable
class.cpp
void init(&myStruct)
{
// Called while booting - no high performance requirements
temp = &myStruct.varA;
//...
}
void foo()
{
//...
int var = *temp; // access struct by helper variable
//...
}