From 936c67415ae058984c5666c44bf68fd1ebfaf23a Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 5 Dec 2018 22:13:41 +0100 Subject: Simplify hex prefix. --- libdevcore/CommonData.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libdevcore') diff --git a/libdevcore/CommonData.cpp b/libdevcore/CommonData.cpp index a289c8ed..1b0e9720 100644 --- a/libdevcore/CommonData.cpp +++ b/libdevcore/CommonData.cpp @@ -32,6 +32,9 @@ using namespace dev; string dev::toHex(bytes const& _data, HexPrefix _prefix, HexCase _case) { std::ostringstream ret; + if (_prefix == HexPrefix::Add) + ret << "0x"; + int rix = _data.size() - 1; for (uint8_t c: _data) { @@ -45,7 +48,7 @@ string dev::toHex(bytes const& _data, HexPrefix _prefix, HexCase _case) ret << std::hex << hexcase << std::setfill('0') << std::setw(2) << size_t(c); } - return (_prefix == HexPrefix::Add) ? "0x" + ret.str() : ret.str(); + return ret.str(); } int dev::fromHex(char _i, WhenError _throw) -- cgit