I have a class, such as one A, that contains a nontrivial member variable of the type LargeType:
class A {
public:
LargeType SetVariable(LargeType var){_var = var;}
LargeType GetVariable(){return _var;}
private:
LargeType _var;
};
I go through a very large dataset and get an object of Atype Aat each iteration. I found that the following code (which happens at least once per iteration):
LargeType var = a.GetVariable();
if(anotherLargeType == var){ DoSomething();}
DoOperation(var);
works slower than the following code:
//---- Version
if(anotherLargeType == a1.GetVariable();){ DoSomething();}
DoOperation(a1.GetVariable());
, №1 , # 2: , . , , № 1 , , a1.GetVariable() . , # 1 # 2 ?