projects
/
oweals
/
minetest.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3deaa7c
)
util/hex.h: Reserve result space in hex_encode()
author
starling13
<starling13@mail.ru>
Sun, 7 Apr 2019 10:01:42 +0000
(13:01 +0300)
committer
SmallJoker
<SmallJoker@users.noreply.github.com>
Sun, 7 Apr 2019 10:01:42 +0000
(12:01 +0200)
Reserve enough space for the result of hex_encode() to eliminate reallocations
src/util/hex.h
patch
|
blob
|
history
diff --git
a/src/util/hex.h
b/src/util/hex.h
index df22539a52673c02c996839de70d1ba522e23329..31bcaa2baad575b2affbd15f137956401e89e2a8 100644
(file)
--- 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';