mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 04:21:51 +00:00
utils: make unpackMsg take const Blob& and inline
Change the template unpackMsg to accept a const Blob& to avoid an unnecessary copy of the Blob argument. Move the non-template unpackMsg (returning msgpack::unpacked) into the header as an inline function and remove its out-of-line definition from src/utils.cpp. Update declarations accordingly.
This commit is contained in:
1 parent
aa000ee586
commit
73dc55155e
2 files changed
+6
-8
No files matched your search
@@ -172,13 +172,17 @@ packMsg(const Type& t)
|
||||
|
||||
template<typename Type>
|
||||
Type
|
||||
unpackMsg(Blob b)
|
||||
unpackMsg(const Blob& b)
|
||||
{
|
||||
msgpack::unpacked msg_res = msgpack::unpack((const char*) b.data(), b.size());
|
||||
return msg_res.get().as<Type>();
|
||||
}
|
||||
|
||||
msgpack::unpacked unpackMsg(Blob b);
|
||||
inline msgpack::unpacked
|
||||
unpackMsg(const Blob& b)
|
||||
{
|
||||
return msgpack::unpack((const char*) b.data(), b.size());
|
||||
}
|
||||
|
||||
msgpack::object* findMapValue(const msgpack::object& map, const char* key, size_t length);
|
||||
|
||||
|
||||
@@ -282,12 +282,6 @@ unpackBlob(const msgpack::object& o)
|
||||
}
|
||||
}
|
||||
|
||||
msgpack::unpacked
|
||||
unpackMsg(Blob b)
|
||||
{
|
||||
return msgpack::unpack((const char*) b.data(), b.size());
|
||||
}
|
||||
|
||||
msgpack::object*
|
||||
findMapValue(const msgpack::object& map, const char* key, size_t key_length)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user