aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorstarling13 <starling13@mail.ru>2019-04-07 13:01:42 +0300
committerSmallJoker <SmallJoker@users.noreply.github.com>2019-04-07 12:01:42 +0200
commit1db4ae96b1a1fa7c5b383a505a0b0b74b836551a (patch)
tree32a52e168d4b6f252dd69896ae17d781445c9a2f /src
parent3deaa7cf57f174a224b433710429b7a9abdbce71 (diff)
downloadminetest-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')
-rw-r--r--src/util/hex.h2
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';