File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 2222#include < sstream>
2323#include < cstdio>
2424
25+ using namespace std ::literals;
26+
2527namespace dht {
2628
2729const HexMap hex_map = {};
@@ -33,9 +35,9 @@ NodeExport::msgpack_unpack(msgpack::object o)
3335 throw msgpack::type_error ();
3436 if (o.via .map .size < 2 )
3537 throw msgpack::type_error ();
36- if (o.via .map .ptr [0 ].key .as <std::string >() != " id" )
38+ if (o.via .map .ptr [0 ].key .as <std::string_view >() != " id" sv )
3739 throw msgpack::type_error ();
38- if (o.via .map .ptr [1 ].key .as <std::string >() != " addr" )
40+ if (o.via .map .ptr [1 ].key .as <std::string_view >() != " addr" sv )
3941 throw msgpack::type_error ();
4042 const auto & addr = o.via .map .ptr [1 ].val ;
4143 if (addr.type != msgpack::type::BIN)
Original file line number Diff line number Diff line change 2424
2525#include < asio.hpp>
2626
27+ using namespace std ::literals;
28+
2729namespace dht {
2830
2931// Organization-local Scope multicast
@@ -61,7 +63,7 @@ class PeerDiscovery::DomainPeerDiscovery
6163
6264 msgpack::sbuffer sbuf_;
6365 std::map<std::string, msgpack::sbuffer> messages_;
64- std::map<std::string, ServiceDiscoveredCallback> callbackmap_;
66+ std::map<std::string, ServiceDiscoveredCallback, std::less<> > callbackmap_;
6567 bool lrunning_ {false };
6668 bool drunning_ {false };
6769
@@ -133,19 +135,18 @@ PeerDiscovery::DomainPeerDiscovery::loopListener()
133135 msgpack::object obj = rcv.get ();
134136
135137 if (obj.type == msgpack::type::STR) {
136- if (lrunning_ and obj.as <std::string >() == " q" )
138+ if (lrunning_ and obj.as <std::string_view >() == " q" sv )
137139 publish (receiveFrom_);
138140 } else if (obj.type == msgpack::type::MAP) {
139141 for (unsigned i = 0 ; i < obj.via .map .size ; i++) {
140142 auto & o = obj.via .map .ptr [i];
141143 if (o.key .type != msgpack::type::STR)
142144 continue ;
143- auto key = o.key .as <std::string>();
144145 ServiceDiscoveredCallback cb;
145146 {
146147 std::lock_guard<std::mutex> lck (dmtx_);
147148 if (drunning_) {
148- auto callback = callbackmap_.find (key);
149+ auto callback = callbackmap_.find (o. key . as <std::string_view>() );
149150 if (callback != callbackmap_.end ())
150151 cb = callback->second ;
151152 } else
You can’t perform that action at this time.
0 commit comments