task payload, initialize jsonValue in constructor
We should do this because it means that variables are only initialized
once. In the simplest case:
struct MyClass{
std::string myString
MyClass(){
myString = "foo";
}
}
in the language, myString is constructed twice, once with empty string,
then a second time with "foo". If you do the construction in the
initializer list for the class the construction only happens once.
Now, the above case is contrived, the optimizer can see through it and
likely optimizes this case because std::string is relatively simple, but
for more complex structures, it's possible this generates less and
bettercompiled code, and this is worth having the check for, and making
our existing code correct.
Tested: cppcheck passing.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ie5c7f293598408d437e7bf7b3fc93b0819e25f9f
diff --git a/redfish-core/ut/lock_test.cpp b/redfish-core/ut/lock_test.cpp
index c27ba68..33c5354 100644
--- a/redfish-core/ut/lock_test.cpp
+++ b/redfish-core/ut/lock_test.cpp
@@ -43,32 +43,31 @@
LockRequest record;
public:
- LockTest()
- {
- record = {
- "xxxxx", "hmc-id", "Read", 234, {{"DontLock", 2}, {"DontLock", 4}}};
+ LockTest() :
// lockrequest with multiple lockrequests
- request = {{"xxxxx",
- "hmc-id",
- "Read",
- 234,
- {{"DontLock", 2}, {"DontLock", 4}}},
- {"xxxxx",
- "hmc-id",
- "Read",
- 234,
- {{"DontLock", 2}, {"DontLock", 4}}}};
- request1 = {{"xxxxx",
- "hmc-id",
- "Read",
- 234,
- {{"DontLock", 2}, {"DontLock", 4}}}};
- request2 = {{"xxxxx",
- "hmc-id",
- "Write",
- 234,
- {{"LockAll", 2}, {"DontLock", 4}}}};
- }
+ request{{"xxxxx",
+ "hmc-id",
+ "Read",
+ 234,
+ {{"DontLock", 2}, {"DontLock", 4}}},
+ {"xxxxx",
+ "hmc-id",
+ "Read",
+ 234,
+ {{"DontLock", 2}, {"DontLock", 4}}}},
+ request1{{"xxxxx",
+ "hmc-id",
+ "Read",
+ 234,
+ {{"DontLock", 2}, {"DontLock", 4}}}},
+ request2{{"xxxxx",
+ "hmc-id",
+ "Write",
+ 234,
+ {{"LockAll", 2}, {"DontLock", 4}}}},
+ record{
+ "xxxxx", "hmc-id", "Read", 234, {{"DontLock", 2}, {"DontLock", 4}}}
+ {}
~LockTest() override = default;