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 22
22
#include < sstream>
23
23
#include < cstdio>
24
24
25
+ using namespace std ::literals;
26
+
25
27
namespace dht {
26
28
27
29
const HexMap hex_map = {};
@@ -33,9 +35,9 @@ NodeExport::msgpack_unpack(msgpack::object o)
33
35
throw msgpack::type_error ();
34
36
if (o.via .map .size < 2 )
35
37
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 )
37
39
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 )
39
41
throw msgpack::type_error ();
40
42
const auto & addr = o.via .map .ptr [1 ].val ;
41
43
if (addr.type != msgpack::type::BIN)
Original file line number Diff line number Diff line change 24
24
25
25
#include < asio.hpp>
26
26
27
+ using namespace std ::literals;
28
+
27
29
namespace dht {
28
30
29
31
// Organization-local Scope multicast
@@ -61,7 +63,7 @@ class PeerDiscovery::DomainPeerDiscovery
61
63
62
64
msgpack::sbuffer sbuf_;
63
65
std::map<std::string, msgpack::sbuffer> messages_;
64
- std::map<std::string, ServiceDiscoveredCallback> callbackmap_;
66
+ std::map<std::string, ServiceDiscoveredCallback, std::less<> > callbackmap_;
65
67
bool lrunning_ {false };
66
68
bool drunning_ {false };
67
69
@@ -133,19 +135,18 @@ PeerDiscovery::DomainPeerDiscovery::loopListener()
133
135
msgpack::object obj = rcv.get ();
134
136
135
137
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 )
137
139
publish (receiveFrom_);
138
140
} else if (obj.type == msgpack::type::MAP) {
139
141
for (unsigned i = 0 ; i < obj.via .map .size ; i++) {
140
142
auto & o = obj.via .map .ptr [i];
141
143
if (o.key .type != msgpack::type::STR)
142
144
continue ;
143
- auto key = o.key .as <std::string>();
144
145
ServiceDiscoveredCallback cb;
145
146
{
146
147
std::lock_guard<std::mutex> lck (dmtx_);
147
148
if (drunning_) {
148
- auto callback = callbackmap_.find (key);
149
+ auto callback = callbackmap_.find (o. key . as <std::string_view>() );
149
150
if (callback != callbackmap_.end ())
150
151
cb = callback->second ;
151
152
} else
You can’t perform that action at this time.
0 commit comments