Skip to content

Commit 1db4ae9

Browse files
starling13SmallJoker
authored andcommittedApr 7, 2019
util/hex.h: Reserve result space in hex_encode()
Reserve enough space for the result of hex_encode() to eliminate reallocations
1 parent 3deaa7c commit 1db4ae9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed
 

‎src/util/hex.h

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ static const char hex_chars[] = "0123456789abcdef";
2626
static inline std::string hex_encode(const char *data, unsigned int data_size)
2727
{
2828
std::string ret;
29+
ret.reserve(data_size * 2);
30+
2931
char buf2[3];
3032
buf2[2] = '\0';
3133

0 commit comments

Comments
 (0)
Please sign in to comment.