Removing unnecessary copies in AvrEvent construction

This commit is contained in:
Nav
2022-03-01 16:57:38 +00:00
parent 1fa88e83f5
commit 893a1d4ac1

View File

@@ -28,22 +28,17 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
"contained invalid event data size."); "contained invalid event data size.");
} }
auto eventData = std::vector<unsigned char>();
/* /*
* Ignore the SOF, protocol version, handler id and sequence ID (which all make up 5 bytes in total, 7 if we * Ignore the SOF, protocol version, handler id and sequence ID (which all make up 5 bytes in total, 7 if we
* include the two size bytes) * include the two size bytes)
*/ */
eventData.insert( this->eventData = std::vector<unsigned char>(
eventData.end(),
responseData.begin() + 7, responseData.begin() + 7,
responseData.begin() + 7 + static_cast<std::int64_t>(responsePacketSize) responseData.begin() + 7 + static_cast<std::int64_t>(responsePacketSize)
); );
this->setEventData(eventData); if (!this->eventData.empty()) {
this->eventId = this->eventData[0];
if (!eventData.empty()) {
this->eventId = eventData[0];
} }
} }
} }