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/task.hpp b/redfish-core/lib/task.hpp
index b40d522..fe3b990 100644
--- a/redfish-core/lib/task.hpp
+++ b/redfish-core/lib/task.hpp
@@ -448,9 +448,10 @@
{
continue; // shouldn't be possible
}
- members.emplace_back(
- nlohmann::json{{"@odata.id", "/redfish/v1/TaskService/Tasks/" +
- std::to_string(task->index)}});
+ nlohmann::json::object_t member;
+ member["@odata.id"] =
+ "redfish/v1/TaskService/Tasks/" + std::to_string(task->index);
+ members.emplace_back(std::move(member));
}
});
}