refactor: Replace if/else with switch cases
This commit is contained in:
1 parent
f41e222f21
commit
d0ee371eec
1 file changed
+20
-14
@@ -599,30 +599,36 @@ class MDConsumerImpl {
|
||||
}
|
||||
LOG(md, Info, "Created MDConsumerImpl for securities: {}", msg.str());
|
||||
|
||||
// Add non-spreads first
|
||||
for (auto &s : symbols) {
|
||||
if (s.type() == SECURITYTYPE_FUTURE ||
|
||||
s.type() == SECURITYTYPE_OPTION ||
|
||||
s.type() == api::SECURITYTYPE_SPOT) {
|
||||
switch (s.type()) {
|
||||
case api::SECURITYTYPE_SPOT:
|
||||
case api::SECURITYTYPE_FUTURE:
|
||||
case api::SECURITYTYPE_OPTION:
|
||||
_instances.push_back(make_shared<MDConsumerInst>(
|
||||
s.symbol(), s.type(), s.exchange(), shared));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// TODO, add options here
|
||||
}
|
||||
bool has_synthetic_instance = false;
|
||||
for (auto &s : symbols) {
|
||||
if (s.type() != SECURITYTYPE_FUTURE) {
|
||||
if (s.type() == SECURITYTYPE_SYNTHETIC) {
|
||||
// Should I look for the shared memory if we have a
|
||||
// ISyntheticSecurityService?
|
||||
if (has_synthetic_instance == false) {
|
||||
_instances.push_back(make_shared<MDConsumerInst>(
|
||||
SYNTHETIC_SYMBOL, s.type(), api::VENUE_BTS, shared));
|
||||
}
|
||||
has_synthetic_instance = true;
|
||||
} else {
|
||||
switch (s.type()) {
|
||||
case api::SECURITYTYPE_SYNTHETIC:
|
||||
if (!has_synthetic_instance) {
|
||||
_instances.push_back(make_shared<MDConsumerInst>(
|
||||
s.symbol(), s.type(), s.exchange(), shared));
|
||||
SYNTHETIC_SYMBOL, s.type(), api::VENUE_BTS, shared));
|
||||
has_synthetic_instance = true;
|
||||
}
|
||||
break;
|
||||
case api::SECURITYTYPE_SPREAD:
|
||||
_instances.push_back(make_shared<MDConsumerInst>(
|
||||
s.symbol(), s.type(), s.exchange(), shared));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user