Skip to content

Commit

Permalink
优化部分数据查询性能
Browse files Browse the repository at this point in the history
  • Loading branch information
lanthora committed Jul 4, 2024
1 parent c5e6c9c commit 976fdba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/core/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#include <atomic>
#include <functional>
#include <list>
#include <map>
#include <shared_mutex>
#include <string>
#include <thread>
#include <unordered_map>

namespace Candy {

Expand Down Expand Up @@ -148,7 +148,7 @@ class Client {
StunCache stun;
PeerInfo selfInfo;
std::shared_mutex ipPeerMutex;
std::map<uint32_t, PeerInfo> ipPeerMap;
std::unordered_map<uint32_t, PeerInfo> ipPeerMap;
std::thread udpThread;
std::thread tickThread;
uint64_t tickTick = randomUint32();
Expand All @@ -170,7 +170,7 @@ class Client {
std::shared_mutex sysRtTableMutex;
std::list<SysRouteEntry> sysRtTable;
std::shared_mutex candyRtTableMutex;
std::map<uint32_t, CandyRouteEntry> candyRtTable;
std::unordered_map<uint32_t, CandyRouteEntry> candyRtTable;
int32_t routeCost;
};

Expand Down
3 changes: 2 additions & 1 deletion src/core/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <map>
#include <string>
#include <thread>
#include <unordered_map>

namespace Candy {

Expand Down Expand Up @@ -52,7 +53,7 @@ class Server {
Address dynamic;
bool dynamicAddrEnabled = false;

std::map<uint32_t, WebSocketConn> ipWsMap;
std::unordered_map<uint32_t, WebSocketConn> ipWsMap;
std::map<WebSocketConn, uint32_t> wsIpMap;
std::map<WebSocketConn, std::string> wsMacMap;
std::list<SysRoute> routes;
Expand Down

0 comments on commit 976fdba

Please sign in to comment.