Skip to content

Commit

Permalink
avoid unnecessary reallocs
Browse files Browse the repository at this point in the history
  • Loading branch information
0vercl0k committed Nov 3, 2024
1 parent 74ffbb8 commit 042571f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/wtf/bochscpu_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1317,8 +1317,15 @@ void BochscpuBackend_t::DumpTenetDelta(const bool Force) {
//

std::string HexString;
HexString.reserve(AccessInfo.Len * 2);
const char HexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
for (size_t Idx = 0; Idx < AccessInfo.Len; Idx++) {
HexString = fmt::format("{}{:02X}", HexString, Buffer[Idx]);
char Hex[3];
Hex[0] = HexDigits[(Buffer[Idx] >> 4) & 0xf];
Hex[1] = HexDigits[(Buffer[Idx] >> 0) & 0xf];
Hex[2] = 0;
HexString.append(Hex);
}

//
Expand Down

0 comments on commit 042571f

Please sign in to comment.