From 042571f869d8cf5902f9c22a2732bde9a836092d Mon Sep 17 00:00:00 2001 From: 0vercl0k <1476421+0vercl0k@users.noreply.github.com> Date: Sun, 3 Nov 2024 09:09:38 -0800 Subject: [PATCH] avoid unnecessary reallocs --- src/wtf/bochscpu_backend.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/wtf/bochscpu_backend.cc b/src/wtf/bochscpu_backend.cc index 1f7cd66..6f418bc 100644 --- a/src/wtf/bochscpu_backend.cc +++ b/src/wtf/bochscpu_backend.cc @@ -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); } //