diff options
author | Ed Tanous <edtanous@google.com> | 2022-07-09 21:17:36 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-09-12 19:42:37 +0300 |
commit | 613dabea03cd2f5cb999be37aaf539280c63ea7a (patch) | |
tree | fbf586118f079918883c97caec8b1b8fd43967f1 /redfish-core/lib/log_services.hpp | |
parent | 188cb6294105a045a445619415d01843de8c3732 (diff) | |
download | bmcweb-613dabea03cd2f5cb999be37aaf539280c63ea7a.tar.xz |
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
Diffstat (limited to 'redfish-core/lib/log_services.hpp')
-rw-r--r-- | redfish-core/lib/log_services.hpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp index faa295adc1..1b52d00f9a 100644 --- a/redfish-core/lib/log_services.hpp +++ b/redfish-core/lib/log_services.hpp @@ -972,9 +972,12 @@ inline void requestRoutesSystemLogServiceCollection(App& app) { nlohmann::json& logServiceArrayLocal = asyncResp->res.jsonValue["Members"]; - logServiceArrayLocal.push_back( - {{"@odata.id", - "/redfish/v1/Systems/system/LogServices/PostCodes"}}); + nlohmann::json::object_t member; + member["@odata.id"] = + "/redfish/v1/Systems/system/LogServices/PostCodes"; + + logServiceArrayLocal.push_back(std::move(member)); + asyncResp->res.jsonValue["Members@odata.count"] = logServiceArrayLocal.size(); return; @@ -2013,8 +2016,9 @@ inline void handleBMCLogServicesCollectionGet( logServiceArray = nlohmann::json::array(); #ifdef BMCWEB_ENABLE_REDFISH_BMC_JOURNAL - logServiceArray.push_back( - {{"@odata.id", "/redfish/v1/Managers/bmc/LogServices/Journal"}}); + nlohmann::json::object_t journal; + journal["@odata.id"] = "/redfish/v1/Managers/bmc/LogServices/Journal"; + logServiceArray.push_back(std::move(journal)); #endif asyncResp->res.jsonValue["Members@odata.count"] = logServiceArray.size(); @@ -2041,15 +2045,17 @@ inline void handleBMCLogServicesCollectionGet( { if (path == "/xyz/openbmc_project/dump/bmc") { - logServiceArrayLocal.push_back( - {{"@odata.id", - "/redfish/v1/Managers/bmc/LogServices/Dump"}}); + nlohmann::json::object_t member; + member["@odata.id"] = + "/redfish/v1/Managers/bmc/LogServices/Dump"; + logServiceArrayLocal.push_back(std::move(member)); } else if (path == "/xyz/openbmc_project/dump/faultlog") { - logServiceArrayLocal.push_back( - {{"@odata.id", - "/redfish/v1/Managers/bmc/LogServices/FaultLog"}}); + nlohmann::json::object_t member; + member["@odata.id"] = + "/redfish/v1/Managers/bmc/LogServices/FaultLog"; + logServiceArrayLocal.push_back(std::move(member)); } } |