Reduced memory allocations when generating raw buffer from EDBG AVR command frames
This commit is contained in:
@@ -81,7 +81,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] auto getRawCommandFrame() const {
|
[[nodiscard]] auto getRawCommandFrame() const {
|
||||||
auto rawCommand = std::vector<unsigned char>(5);
|
auto rawCommand = std::vector<unsigned char>(5 + this->payload.size());
|
||||||
|
|
||||||
rawCommand[0] = 0x0E; // Start of frame
|
rawCommand[0] = 0x0E; // Start of frame
|
||||||
rawCommand[1] = 0x00; // Protocol version
|
rawCommand[1] = 0x00; // Protocol version
|
||||||
@@ -92,11 +92,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
|||||||
rawCommand[4] = static_cast<unsigned char>(this->protocolHandlerId);
|
rawCommand[4] = static_cast<unsigned char>(this->protocolHandlerId);
|
||||||
|
|
||||||
if (!this->payload.empty()) {
|
if (!this->payload.empty()) {
|
||||||
rawCommand.insert(
|
std::copy(this->payload.begin(), this->payload.end(), rawCommand.begin() + 5);
|
||||||
rawCommand.end(),
|
|
||||||
this->payload.begin(),
|
|
||||||
this->payload.end()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rawCommand;
|
return rawCommand;
|
||||||
|
|||||||
Reference in New Issue
Block a user