Pretty simple question, I have an object (say Obj) which has member variable (say "var"). In one function I need to access this property multiple times (4 to 5 times). What I am doing right now is everytime I do Obj.var to get the value. Is is right (from optimization point of view) to do that or I should store Obj.var in a temporary variable and then use this variable? I am looking for explanation from "how both approaches impact performance" point of view.
=====
What if Obj.var is replaced by Obj.getVar(), a getter method for that variable? How will it impact the performance?