summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-06-12 23:47:05 +0200
committerLioncash <mathew1800@gmail.com>2019-06-12 23:54:11 +0200
commit969cd6dc1d60acd98c89815dd53c11bf4dac2518 (patch)
tree56f5632abd17d87ef128d8029b86438d928bcd97 /src/common
parentcommon/hex_util: Combine HexVectorToString() and HexArrayToString() (diff)
downloadyuzu-969cd6dc1d60acd98c89815dd53c11bf4dac2518.tar
yuzu-969cd6dc1d60acd98c89815dd53c11bf4dac2518.tar.gz
yuzu-969cd6dc1d60acd98c89815dd53c11bf4dac2518.tar.bz2
yuzu-969cd6dc1d60acd98c89815dd53c11bf4dac2518.tar.lz
yuzu-969cd6dc1d60acd98c89815dd53c11bf4dac2518.tar.xz
yuzu-969cd6dc1d60acd98c89815dd53c11bf4dac2518.tar.zst
yuzu-969cd6dc1d60acd98c89815dd53c11bf4dac2518.zip
Diffstat (limited to 'src/common')
-rw-r--r--src/common/hex_util.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/common/hex_util.h b/src/common/hex_util.h
index a64c9b485..bb4736f96 100644
--- a/src/common/hex_util.h
+++ b/src/common/hex_util.h
@@ -36,10 +36,15 @@ std::string HexToString(const ContiguousContainer& data, bool upper = true) {
static_assert(std::is_same_v<typename ContiguousContainer::value_type, u8>,
"Underlying type within the contiguous container must be u8.");
+ constexpr std::size_t pad_width = 2;
+
std::string out;
+ out.reserve(std::size(data) * pad_width);
+
for (const u8 c : data) {
out += fmt::format(upper ? "{:02X}" : "{:02x}", c);
}
+
return out;
}