Let's say there's a section of code which takes a big chunk of the overall program time (~20%), which consists on converting from a given type (among options: string, char, short, int, float, unsigneds, ...) to string. The easy way to do this would be something like:
template<class T>
string toString(T sAttrvalue) {
stringstream ss;
ss << T;
string res=ss.str();
if(res=="x" || res=="y")
return "k";
return res;
}
But the performance is too poor (even if it improves by using a static stringstream and doing ss.str("") in the beginning of the function).
Any other ideas on how to make it go faster? (what would you think of using another function argument which specifies the time and, from there, use sprintf?)