logger.cc/logger_build_init_data(): reuse params_map (#21811)

* faster log params

* Update selfdrive/loggerd/logger.cc

* fix build

Co-authored-by: Willem Melching <willem.melching@gmail.com>
old-commit-hash: fecdf16f6b
commatwo_master
Dean Lee 4 years ago committed by GitHub
parent cce6e3e6e0
commit 7fed9b0c0c
  1. 31
      selfdrive/loggerd/logger.cc

@ -94,22 +94,23 @@ kj::Array<capnp::word> logger_build_init_data() {
init.setDirty(!getenv("CLEAN")); init.setDirty(!getenv("CLEAN"));
// log params // log params
Params params = Params(); auto params = Params();
init.setGitCommit(params.get("GitCommit")); std::map<std::string, std::string> params_map = params.readAll();
init.setGitBranch(params.get("GitBranch"));
init.setGitRemote(params.get("GitRemote")); init.setGitCommit(params_map["GitCommit"]);
init.setGitBranch(params_map["GitBranch"]);
init.setGitRemote(params_map["GitRemote"]);
init.setPassive(params.getBool("Passive")); init.setPassive(params.getBool("Passive"));
init.setDongleId(params.get("DongleId")); init.setDongleId(params_map["DongleId"]);
{
std::map<std::string, std::string> params_map = params.readAll(); auto lparams = init.initParams().initEntries(params_map.size());
auto lparams = init.initParams().initEntries(params_map.size()); int i = 0;
int i = 0; for (auto& [key, value] : params_map) {
for (auto& kv : params_map) { auto lentry = lparams[i];
auto lentry = lparams[i]; lentry.setKey(key);
lentry.setKey(kv.first); lentry.setValue(capnp::Data::Reader((const kj::byte*)value.data(), value.size()));
lentry.setValue(capnp::Data::Reader((const kj::byte*)kv.second.data(), kv.second.size())); i++;
i++;
}
} }
return capnp::messageToFlatArray(msg); return capnp::messageToFlatArray(msg);
} }

Loading…
Cancel
Save