Author: lslezak Date: Wed Jun 17 15:25:20 2009 New Revision: 57616 URL: http://svn.opensuse.org/viewcvs/yast?rev=57616&view=rev Log: - optimization - type check is recursive, do it just once at the beginning (do not repeat it in every recursive call) Modified: branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.cc Modified: branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.cc?rev=57616&r1=57615&r2=57616&view=diff ============================================================================== --- branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.cc (original) +++ branches/tmp/lslezak/core/liby2dbus/src/DBusMsg.cc Wed Jun 17 15:25:20 2009 @@ -228,36 +228,24 @@ { if (val.isNull()) { - y2milestone("Ignoring YCPNull value"); + y2error("Ignoring YCPNull value"); return false; } y2debug("Adding YCP value: %s", val->toString().c_str()); - // create insert iterator - DBusMessageIter it; - dbus_message_iter_init_append(msg, &it); - - // add the value - bool ret = addValueAt(val, &it, rettype); - - return ret; -} - -bool DBusMsg::addValueAt(const YCPValue &val, DBusMessageIter *i, constTypePtr rtype) -{ - if (!rtype) + if (!rettype) { // return as the current type if not specified - rtype = Type::vt2type(val->valuetype()); + rettype = Type::vt2type(val->valuetype()); } else { // the required type does not match the value - if (rtype->matchvalue(val) < 0) + if (rettype->matchvalue(val) < 0) { y2error("Value %s does not match requested type %s", - val->toString().c_str(), rtype->toString().c_str()); + val->toString().c_str(), rettype->toString().c_str()); return false; } else @@ -266,6 +254,19 @@ } } + + // create insert iterator + DBusMessageIter it; + dbus_message_iter_init_append(msg, &it); + + // add the value + bool ret = addValueAt(val, &it, rettype); + + return ret; +} + +bool DBusMsg::addValueAt(const YCPValue &val, DBusMessageIter *i, constTypePtr rtype) +{ y2milestone("Returning YCP value as type: %s", rtype->toString().c_str()); int type = typeInt(val); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org