Remove nlohmann brace initialization
There's a few last places (outside of tests) where we still use
nlohmann brace initialization. Per the transforms we've been doing,
move these to constructing the objects explicitly, using operator[],
nlohmann::object_t and nlohmann::array_t. Theses were found by manual
inspection grepping for all uses of nlohmann::json.
This is done to reduce binary size and reduce the number of intermediate
objects being constructed. This commit saves a trivial amount of size
(~4KB, Half a percent of total) and in addition but makes our
construction consistent.
Tested:
Redfish service validator passes.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I7478479a9fdc41b254eef325002d413c1fb411a0
diff --git a/redfish-core/lib/trigger.hpp b/redfish-core/lib/trigger.hpp
index 5e2f050..811d355 100644
--- a/redfish-core/lib/trigger.hpp
+++ b/redfish-core/lib/trigger.hpp
@@ -100,13 +100,12 @@
{
return std::nullopt;
}
-
- triggers.push_back({
- {"Name", name},
- {"Severity", severity},
- {"DwellTime", *duration},
- {"Value", value},
- });
+ nlohmann::json::object_t trigger;
+ trigger["Name"] = name;
+ trigger["Severity"] = severity;
+ trigger["DwellTime"] = *duration;
+ trigger["Value"] = value;
+ triggers.push_back(std::move(trigger));
}
return {std::move(triggers)};