boardd: use setUbloxRaw to avoid memory alloc&copy in pigeon_publish_raw (#19884)

* use setUbloxRaw to avoid memory copy

* const std::string &dat
old-commit-hash: 0f8b5db8cefdd53c06ffd4867b8915d12f6e4603
This commit is contained in:
Dean Lee
2021-01-27 00:21:02 +08:00
committed by GitHub
parent bf95f37eba
commit b16842b512
+3 -5
View File
@@ -462,16 +462,14 @@ void hardware_control_thread() {
}
}
static void pigeon_publish_raw(PubMaster &pm, std::string dat) {
static void pigeon_publish_raw(PubMaster &pm, const std::string &dat) {
// create message
MessageBuilder msg;
auto ublox_raw = msg.initEvent().initUbloxRaw(dat.length());
memcpy(ublox_raw.begin(), dat.data(), dat.length());
capnp::Data::Builder ublox_row((uint8_t*)dat.data(), dat.length());
msg.initEvent().setUbloxRaw(ublox_row);
pm.send("ubloxRaw", msg);
}
void pigeon_thread() {
if (!panda->is_pigeon){ return; };