[CTRL++] Reduce temporary objects

Every assignment of object and values to another object or value takes some time because it is a copy of the memory.

// Instead ofSomeClass mo1 = getSomeModelObject();AnotherClass mo2 = getAnotherModelObject();doSomething(mo1, mo2);// consider:doSomething(getSomeModelObject(), getAnotherModelObject());

 

For speed improvement it is recommended to avoid temporary objects if not needed later on again.

shared_ptr<ClassA> a = new ClassA();...a = nullptr; // if you do not need it anymore in the scope destroy...
Date added:
Last revised:
Hits:
11.121
Rating:
Rating: 4.1. 34 vote(s).
34 anonymous votes
No rating done at all.
Your vote was '' (0 of 5) You are an anonymous user.
You may log on to do personalized votings
Click the rating bar to rate this item Please log on to do ratings
  • Notification

    FE user cannot be identified! (1403201096)

Tags:
Programming / Scripting, OOP