diff options
author | starling13 <starling13@mail.ru> | 2019-04-07 13:01:42 +0300 |
---|---|---|
committer | SmallJoker <SmallJoker@users.noreply.github.com> | 2019-04-07 12:01:42 +0200 |
commit | 1db4ae96b1a1fa7c5b383a505a0b0b74b836551a (patch) | |
tree | 32a52e168d4b6f252dd69896ae17d781445c9a2f /src/util/hex.h | |
parent | 3deaa7cf57f174a224b433710429b7a9abdbce71 (diff) | |
download | minetest-1db4ae96b1a1fa7c5b383a505a0b0b74b836551a.tar.gz minetest-1db4ae96b1a1fa7c5b383a505a0b0b74b836551a.tar.bz2 minetest-1db4ae96b1a1fa7c5b383a505a0b0b74b836551a.zip |
util/hex.h: Reserve result space in hex_encode()
Reserve enough space for the result of hex_encode() to eliminate reallocations
Diffstat (limited to 'src/util/hex.h')
-rw-r--r-- | src/util/hex.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/util/hex.h b/src/util/hex.h index df22539a5..31bcaa2ba 100644 --- a/src/util/hex.h +++ b/src/util/hex.h @@ -26,6 +26,8 @@ static const char hex_chars[] = "0123456789abcdef"; static inline std::string hex_encode(const char *data, unsigned int data_size) { std::string ret; + ret.reserve(data_size * 2); + char buf2[3]; buf2[2] = '\0'; |