diff options
author | attilamolnar <attilamolnar@hush.com> | 2013-05-16 15:34:45 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-05-18 21:07:42 +0200 |
commit | 780757cbc172daa4d9973e8e3b87fd42cfac5541 (patch) | |
tree | 0a4d3a8ebfd8c3bd992537a7349ff02aa48389a0 /src/inspstring.cpp | |
parent | 8f27fefa75e2952e7ab8757eb9fe4af4586817f0 (diff) |
Deduplicate hex string creation code
Diffstat (limited to 'src/inspstring.cpp')
-rw-r--r-- | src/inspstring.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/inspstring.cpp b/src/inspstring.cpp index 72d6c64c8..7fa4762c5 100644 --- a/src/inspstring.cpp +++ b/src/inspstring.cpp @@ -23,16 +23,16 @@ static const char hextable[] = "0123456789abcdef"; -std::string BinToHex(const std::string& data) +std::string BinToHex(const void* raw, size_t l) { - int l = data.length(); + const char* data = static_cast<const char*>(raw); std::string rv; rv.reserve(l * 2); - for(int i=0; i < l; i++) + for (size_t i = 0; i < l; i++) { unsigned char c = data[i]; - rv.append(1, hextable[c >> 4]); - rv.append(1, hextable[c & 0xF]); + rv.push_back(hextable[c >> 4]); + rv.push_back(hextable[c & 0xF]); } return rv; } |