On Fri, Oct 07, 2011 at 04:53:28PM +0200, Ladislav Slezak wrote:
Dne 7.10.2011 11:16, jsuchome@svn2.opensuse.org napsal(a):
-string SnapperAgent::getValue (const YCPMap map, const string key) +string SnapperAgent::getValue (const YCPMap map, const string key, string deflt) { if (!map->value(YCPString(key)).isNull() && map->value(YCPString(key))->isString()) return map->value(YCPString(key))->asString()->value(); else - return ""; + return deflt; }
The "key" parameter is not changed so you could pass a reference to it ("const string &key"), that will prevent from creating unnecessary copy of the string on function call.
"deflt" is also not changed, passing "const string &deflt" would help
Right. The same for const YCPMap& map.
(I'm not sure, I'm not C++ expert, but then you might need to create the copy explicitly via
return string(deflt);
at the end.)
That's unnecessary, because the constructor string(const string&) is not marked "explicit". -- Martin Vidner, YaST developer http://en.opensuse.org/User:Mvidner Kuracke oddeleni v restauraci je jako fekalni oddeleni v bazenu