Commit 25a6bd3f authored by Adrien Béraud's avatar Adrien Béraud Committed by Sébastien Blin

namedirectory: don't create temporary items during lookup

Change-Id: Icc3c9fd79c01641d8280eff0ffccf8dfe889d1a7
parent 9f249126
......@@ -109,6 +109,9 @@ NameDirectory::instance(const std::string& server, std::shared_ptr<dht::Logger>
std::lock_guard<std::mutex> lock(instanceMtx);
static std::map<std::string, NameDirectory> instances {};
auto it = instances.find(s);
if (it != instances.end())
return it->second;
auto r = instances.emplace(std::piecewise_construct,
std::forward_as_tuple(s),
std::forward_as_tuple(s, l));
......
......@@ -60,7 +60,6 @@ public:
using LookupCallback = std::function<void(const std::string& result, Response response)>;
using RegistrationCallback = std::function<void(RegistrationResponse response)>;
NameDirectory() {}
NameDirectory(const std::string& s, std::shared_ptr<dht::Logger> l = {});
void load();
......@@ -84,6 +83,7 @@ public:
private:
NON_COPYABLE(NameDirectory);
NameDirectory(NameDirectory&&) = delete;
NameDirectory& operator=(NameDirectory&&) = delete;
constexpr static const char* const DEFAULT_SERVER_HOST = "ns.jami.net";
const std::string serverHost_ {DEFAULT_SERVER_HOST};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment