Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MessageState: pre-allocating tmp_vals #1055

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions can/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class MessageState {
std::vector<Signal> parse_sigs;
std::vector<double> vals;
std::vector<std::vector<double>> all_vals;
std::vector<double> tmp_vals;

uint64_t last_seen_nanos;
uint64_t check_threshold;
Expand Down
3 changes: 2 additions & 1 deletion can/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ int64_t get_raw_value(const std::vector<uint8_t> &msg, const Signal &sig) {


bool MessageState::parse(uint64_t nanos, const std::vector<uint8_t> &dat) {
std::vector<double> tmp_vals(parse_sigs.size());
bool checksum_failed = false;
bool counter_failed = false;

Expand Down Expand Up @@ -128,6 +127,7 @@ CANParser::CANParser(int abus, const std::string& dbc_name, const std::vector<st
state.parse_sigs = msg->sigs;
state.vals.resize(msg->sigs.size());
state.all_vals.resize(msg->sigs.size());
state.tmp_vals.resize(msg->sigs.size());
}
}

Expand All @@ -147,6 +147,7 @@ CANParser::CANParser(int abus, const std::string& dbc_name, bool ignore_checksum
.ignore_counter = ignore_counter,
};

state.tmp_vals.resize(msg.sigs.size());
for (const auto& sig : msg.sigs) {
state.parse_sigs.push_back(sig);
state.vals.push_back(0);
Expand Down