Skip to content

Commit

Permalink
libusb/serialInterface: Cleaned up the result string creation in read…
Browse files Browse the repository at this point in the history
…Packet()
  • Loading branch information
dragonmux committed Jan 16, 2024
1 parent 65fe784 commit f6b140d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/libusb/serialInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,8 @@ std::string serialInterface_t::readPacket() const
throw bmpCommsError_t{};
// Figure out how long that is (minus the beginning '&' and ending '#')
const auto length{std::strlen(packet.data() + 1U) - 1U};
// Make a new std::string of an appropriate length
std::string result(length + 1U, '\0');
// And copy the result string in, returning it
std::memcpy(result.data(), packet.data() + 1U, length);
// Make a new std::string of an appropriate length, copying the data in to return it
std::string result{packet.data() + 1U, length};
console.debug("Remote read: "sv, result);
return result;
}

0 comments on commit f6b140d

Please sign in to comment.