Skip to content

Commit

Permalink
Minor improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
levlam committed Oct 27, 2023
1 parent 7097b2b commit 9c9c1bb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions td/telegram/net/DcOptionsSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ vector<DcOptionsSet::ConnectionInfo> DcOptionsSet::find_all_connections(DcId dc_
if (!static_options.empty()) {
options = std::move(static_options);
} else {
bool have_ipv4 = td::any_of(options, [](const auto &v) { return !v.option->is_ipv6(); });
bool have_ipv4 = any_of(options, [](const auto &v) { return !v.option->is_ipv6(); });
if (have_ipv4) {
td::remove_if(options, [](auto &v) { return v.option->is_ipv6(); });
}
Expand All @@ -122,13 +122,13 @@ vector<DcOptionsSet::ConnectionInfo> DcOptionsSet::find_all_connections(DcId dc_
}

if (prefer_ipv6) {
bool have_ipv6 = td::any_of(options, [](const auto &v) { return v.option->is_ipv6(); });
bool have_ipv6 = any_of(options, [](const auto &v) { return v.option->is_ipv6(); });
if (have_ipv6) {
td::remove_if(options, [](auto &v) { return !v.option->is_ipv6(); });
}
}

bool have_media_only = td::any_of(options, [](const auto &v) { return v.option->is_media_only(); });
bool have_media_only = any_of(options, [](const auto &v) { return v.option->is_media_only(); });
if (have_media_only) {
td::remove_if(options, [](auto &v) { return !v.option->is_media_only(); });
}
Expand Down
5 changes: 3 additions & 2 deletions tddb/td/db/BinlogKeyValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "td/utils/buffer.h"
#include "td/utils/common.h"
#include "td/utils/FlatHashMap.h"
#include "td/utils/HashTableUtils.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/port/RwMutex.h"
Expand Down Expand Up @@ -219,9 +220,9 @@ class BinlogKeyValue final : public KeyValueSyncInterface {
binlog_->lazy_sync(std::move(promise));
}

std::unordered_map<string, string> prefix_get(Slice prefix) final {
std::unordered_map<string, string, Hash<string>> prefix_get(Slice prefix) final {
auto lock = rw_mutex_.lock_write().move_as_ok();
std::unordered_map<string, string> res;
std::unordered_map<string, string, Hash<string>> res;
for (const auto &kv : map_) {
if (begins_with(kv.first, prefix)) {
res.emplace(kv.first.substr(prefix.size()), kv.second.first);
Expand Down
3 changes: 2 additions & 1 deletion tddb/td/db/KeyValueSyncInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "td/utils/common.h"
#include "td/utils/FlatHashMap.h"
#include "td/utils/HashTableUtils.h"
#include "td/utils/Promise.h"
#include "td/utils/Slice.h"

Expand All @@ -34,7 +35,7 @@ class KeyValueSyncInterface {

virtual string get(const string &key) = 0;

virtual std::unordered_map<string, string> prefix_get(Slice prefix) = 0;
virtual std::unordered_map<string, string, Hash<string>> prefix_get(Slice prefix) = 0;

virtual FlatHashMap<string, string> get_all() = 0;

Expand Down
2 changes: 1 addition & 1 deletion tdutils/td/utils/FloodControlStrict.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace td {

// More strict implementaions of flood control than FloodControlFast.
// More strict implementations of flood control than FloodControlFast.
// Should be just fine for small counters.
class FloodControlStrict {
public:
Expand Down

0 comments on commit 9c9c1bb

Please sign in to comment.