When should I use temporary variables?
- by Kyle
Specifically, I'm wondering which of these I should write:
shared_ptr<GuiContextMenu> subMenu = items[j].subMenu.lock();
if (subMenu)
subMenu->setVisible(false);
or:
if (items[j].subMenu.lock()
items[j].subMenu.lock()->setVisible(false);
I am not required to follow any style guidelines. After optimization, I don't think either choice makes a difference in performance. What is generally the preferred style and why?