init message_states map without making copies (#355)

This commit is contained in:
Dean Lee 2021-03-09 23:11:09 +08:00 committed by GitHub
parent 419471253a
commit ae058828cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 8 deletions

View File

@ -115,17 +115,15 @@ CANParser::CANParser(int abus, const std::string& dbc_name,
init_crc_lookup_tables();
for (const auto& op : options) {
MessageState state = {
.address = op.address,
// .check_frequency = op.check_frequency,
};
MessageState &state = message_states[op.address];
state.address = op.address;
// state.check_frequency = op.check_frequency,
// msg is not valid if a message isn't received for 10 consecutive steps
if (op.check_frequency > 0) {
state.check_threshold = (1000000000ULL / op.check_frequency) * 10;
}
const Msg* msg = NULL;
for (int i=0; i<dbc->num_msgs; i++) {
if (dbc->msgs[i].address == op.address) {
@ -162,10 +160,7 @@ CANParser::CANParser(int abus, const std::string& dbc_name,
break;
}
}
}
message_states[state.address] = state;
}
}