sdbus++: interface: move variant constructor inline
This saves approximately 250K in the libphosphor_dbus.so on x86.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ie0786cdbe2cac865f53c0874e5b1218c2208c09c
diff --git a/tools/sdbusplus/templates/interface.server.cpp.mako b/tools/sdbusplus/templates/interface.server.cpp.mako
index 6edc845..fa1c12d 100644
--- a/tools/sdbusplus/templates/interface.server.cpp.mako
+++ b/tools/sdbusplus/templates/interface.server.cpp.mako
@@ -18,19 +18,6 @@
namespace sdbusplus::${interface.cppNamespace()}
{
- % if interface.properties:
-${classname}::${classname}(bus_t& bus, const char* path,
- const std::map<std::string, PropertiesVariant>& vals,
- bool skipSignal)
- : ${classname}(bus, path)
-{
- for (const auto& v : vals)
- {
- setPropertyByName(v.first, v.second, skipSignal);
- }
-}
-
- % endif
% for m in interface.methods:
${ m.cpp_prototype(loader, interface=interface, ptype='callback-cpp') }
% endfor
diff --git a/tools/sdbusplus/templates/interface.server.hpp.mako b/tools/sdbusplus/templates/interface.server.hpp.mako
index a98a3c4..4000e14 100644
--- a/tools/sdbusplus/templates/interface.server.hpp.mako
+++ b/tools/sdbusplus/templates/interface.server.hpp.mako
@@ -29,6 +29,9 @@
class ${classname}
{
public:
+ static constexpr auto interface =
+ "${interface.name}";
+
/* Define all of the basic class operations:
* Not allowed:
* - Default constructor to avoid nullptrs.
@@ -67,7 +70,6 @@
% if interface.properties:
using PropertiesVariant = sdbusplus::utility::dedup_variant_t<
${",\n ".join(sorted(setOfPropertyTypes()))}>;
-
/** @brief Constructor to initialize the object from a map of
* properties.
*
@@ -77,7 +79,14 @@
*/
${classname}(bus_t& bus, const char* path,
const std::map<std::string, PropertiesVariant>& vals,
- bool skipSignal = false);
+ bool skipSignal = false) :
+ ${classname}(bus, path)
+ {
+ for (const auto& v : vals)
+ {
+ setPropertyByName(v.first, v.second, skipSignal);
+ }
+ }
% endif
% for m in interface.methods:
@@ -154,7 +163,6 @@
_${"_".join(interface.name.split('.'))}_interface.emit_removed();
}
- static constexpr auto interface = "${interface.name}";
private:
% for m in interface.methods: