Dne 10.10.2011 12:54, [email protected] napsal(a):

> --- trunk/snapper/agent-snapper/src/SnapperAgent.cc (original)
> +++ trunk/snapper/agent-snapper/src/SnapperAgent.cc Mon Oct 10 12:54:07 2011
> @@ -18,7 +18,7 @@
>  /*
>   * search the map for value of given key; both key and value have to be 
> strings
>   */
> -string SnapperAgent::getValue (const YCPMap map, const string key, string 
> deflt)
> +string SnapperAgent::getValue (const YCPMap &map, const string key, const 
> string deflt)

Parameters key and deflt should be passed as a reference (missing & there).
(If the parameter is 'const' type it's safe to use a reference to it.)

>      if (!map->value(YCPString(key)).isNull()
>       && map->value(YCPString(key))->isString())
> -int SnapperAgent::getIntValue (const YCPMap map, const string key, int deflt)
> +int SnapperAgent::getIntValue (const YCPMap &map, const string key, const 
> int deflt)

The same here and at some more places. (Just const reference to int doesn't make
sense here.)

>  {
>      if (!map->value(YCPString(key)).isNull() && 
> map->value(YCPString(key))->isInteger()) {
>       return map->value(YCPString(key))->asInteger()->value(); 

I think you can avoid recreating YCPString object several times and searching 
in the
map by storing it into an YCPValue variable (it's like any in YCP):

   YCPValue val = map->value(YCPString(key));

   if (!val.isNull() && val->isInteger()) {
        return val->asInteger()->value();

(well, IIRC this could be also used in pkg-bindings at some places...)

--

Ladislav Slezák
Appliance department / YaST Developer
Lihovarská 1060/12
190 00 Prague 9 / Czech Republic
tel: +420 284 028 960
[email protected]
SUSE
-- 
To unsubscribe, e-mail: [email protected]
To contact the owner, e-mail: [email protected]

Reply via email to