Prefer std::unordered_map to std::map.

This commit is contained in:
levlam 2021-08-21 21:42:07 +03:00
parent d229c5daed
commit 43d9ba81ac
4 changed files with 7 additions and 6 deletions

View File

@ -26,8 +26,8 @@
#include "td/utils/Status.h" #include "td/utils/Status.h"
#include "td/utils/StorerBase.h" #include "td/utils/StorerBase.h"
#include <map>
#include <memory> #include <memory>
#include <unordered_map>
#include <utility> #include <utility>
namespace td { namespace td {
@ -130,7 +130,7 @@ class RawConnectionDefault final : public RawConnection {
PublicFields extra_; PublicFields extra_;
BufferedFd<SocketFd> socket_fd_; BufferedFd<SocketFd> socket_fd_;
unique_ptr<IStreamTransport> transport_; unique_ptr<IStreamTransport> transport_;
std::map<uint32, uint64> quick_ack_to_token_; std::unordered_map<uint32, uint64> quick_ack_to_token_;
bool has_error_{false}; bool has_error_{false};
unique_ptr<StatsCallback> stats_callback_; unique_ptr<StatsCallback> stats_callback_;

View File

@ -26,9 +26,9 @@
#include "td/utils/type_traits.h" #include "td/utils/type_traits.h"
#include <functional> #include <functional>
#include <map>
#include <memory> #include <memory>
#include <type_traits> #include <type_traits>
#include <unordered_map>
#include <utility> #include <utility>
namespace td { namespace td {
@ -214,7 +214,7 @@ class Scheduler {
ListNode ready_actors_list_; ListNode ready_actors_list_;
KHeap<double> timeout_queue_; KHeap<double> timeout_queue_;
std::map<ActorInfo *, std::vector<Event>> pending_events_; std::unordered_map<ActorInfo *, std::vector<Event>> pending_events_;
ServiceActor service_actor_; ServiceActor service_actor_;
Poll poll_; Poll poll_;

View File

@ -24,9 +24,9 @@
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#include <cstring> #include <cstring>
#include <map>
#include <memory> #include <memory>
#include <mutex> #include <mutex>
#include <unordered_map>
#if TD_PORT_WINDOWS #if TD_PORT_WINDOWS
#include <wincrypt.h> #include <wincrypt.h>
@ -131,7 +131,7 @@ int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) {
static std::mutex warning_mutex; static std::mutex warning_mutex;
{ {
std::lock_guard<std::mutex> lock(warning_mutex); std::lock_guard<std::mutex> lock(warning_mutex);
static std::map<std::string, double> next_warning_time; static std::unordered_map<std::string, double> next_warning_time;
double &next = next_warning_time[warning]; double &next = next_warning_time[warning];
if (next <= now) { if (next <= now) {
next = now + 300; // one warning per 5 minutes next = now + 300; // one warning per 5 minutes

View File

@ -5,6 +5,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// //
#include <iostream> #include <iostream>
#include <map>
#include <tdutils/td/utils/FileLog.h> #include <tdutils/td/utils/FileLog.h>
#include <tdutils/td/utils/OptionParser.h> #include <tdutils/td/utils/OptionParser.h>
#include <tdutils/td/utils/port/path.h> #include <tdutils/td/utils/port/path.h>