Remove unneded explicit td::.

GitOrigin-RevId: e3888510ce72a55072a11d105311f07b4ba42bbf
This commit is contained in:
levlam 2019-09-15 06:19:46 +03:00
parent 8949e040b8
commit f29c4a9ed1
20 changed files with 81 additions and 82 deletions

View File

@ -456,7 +456,7 @@ Status TlsInit::wait_hello_response() {
std::string hash_dest(32, '\0'); std::string hash_dest(32, '\0');
hmac_sha256(password_, PSLICE() << hello_rand_ << response.as_slice(), hash_dest); hmac_sha256(password_, PSLICE() << hello_rand_ << response.as_slice(), hash_dest);
if (hash_dest != response_rand) { if (hash_dest != response_rand) {
return td::Status::Error("Response hash mismatch"); return Status::Error("Response hash mismatch");
} }
stop(); stop();

View File

@ -175,7 +175,7 @@ size_t do_calc_crypto_size2_basic(size_t data_size, size_t enc_size, size_t raw_
} }
size_t do_calc_crypto_size2_rand(size_t data_size, size_t enc_size, size_t raw_size) { size_t do_calc_crypto_size2_rand(size_t data_size, size_t enc_size, size_t raw_size) {
size_t rand_data_size = td::Random::secure_uint32() & 0xff; size_t rand_data_size = Random::secure_uint32() & 0xff;
size_t encrypted_size = (enc_size + data_size + rand_data_size + 12 + 15) & ~15; size_t encrypted_size = (enc_size + data_size + rand_data_size + 12 + 15) & ~15;
return raw_size + encrypted_size; return raw_size + encrypted_size;
} }

View File

@ -6117,7 +6117,7 @@ void MessagesManager::on_update_dialog_notify_settings(
return; return;
} }
const DialogNotificationSettings notification_settings = td::get_dialog_notification_settings( const DialogNotificationSettings notification_settings = ::td::get_dialog_notification_settings(
std::move(peer_notify_settings), current_settings->use_default_disable_pinned_message_notifications, std::move(peer_notify_settings), current_settings->use_default_disable_pinned_message_notifications,
current_settings->disable_pinned_message_notifications, current_settings->disable_pinned_message_notifications,
current_settings->use_default_disable_mention_notifications, current_settings->disable_mention_notifications); current_settings->use_default_disable_mention_notifications, current_settings->disable_mention_notifications);
@ -6137,7 +6137,7 @@ void MessagesManager::on_update_scope_notify_settings(
auto old_notification_settings = get_scope_notification_settings(scope); auto old_notification_settings = get_scope_notification_settings(scope);
CHECK(old_notification_settings != nullptr); CHECK(old_notification_settings != nullptr);
const ScopeNotificationSettings notification_settings = td::get_scope_notification_settings( const ScopeNotificationSettings notification_settings = ::td::get_scope_notification_settings(
std::move(peer_notify_settings), old_notification_settings->disable_pinned_message_notifications, std::move(peer_notify_settings), old_notification_settings->disable_pinned_message_notifications,
old_notification_settings->disable_mention_notifications); old_notification_settings->disable_mention_notifications);
if (!notification_settings.is_synchronized) { if (!notification_settings.is_synchronized) {
@ -27150,7 +27150,7 @@ void MessagesManager::get_payment_form(FullMessageId full_message_id,
return promise.set_error(r_message_id.move_as_error()); return promise.set_error(r_message_id.move_as_error());
} }
td::get_payment_form(r_message_id.ok(), std::move(promise)); ::td::get_payment_form(r_message_id.ok(), std::move(promise));
} }
void MessagesManager::validate_order_info(FullMessageId full_message_id, tl_object_ptr<td_api::orderInfo> order_info, void MessagesManager::validate_order_info(FullMessageId full_message_id, tl_object_ptr<td_api::orderInfo> order_info,
@ -27161,7 +27161,7 @@ void MessagesManager::validate_order_info(FullMessageId full_message_id, tl_obje
return promise.set_error(r_message_id.move_as_error()); return promise.set_error(r_message_id.move_as_error());
} }
td::validate_order_info(r_message_id.ok(), std::move(order_info), allow_save, std::move(promise)); ::td::validate_order_info(r_message_id.ok(), std::move(order_info), allow_save, std::move(promise));
} }
void MessagesManager::send_payment_form(FullMessageId full_message_id, const string &order_info_id, void MessagesManager::send_payment_form(FullMessageId full_message_id, const string &order_info_id,
@ -27173,7 +27173,7 @@ void MessagesManager::send_payment_form(FullMessageId full_message_id, const str
return promise.set_error(r_message_id.move_as_error()); return promise.set_error(r_message_id.move_as_error());
} }
td::send_payment_form(r_message_id.ok(), order_info_id, shipping_option_id, credentials, std::move(promise)); ::td::send_payment_form(r_message_id.ok(), order_info_id, shipping_option_id, credentials, std::move(promise));
} }
void MessagesManager::get_payment_receipt(FullMessageId full_message_id, void MessagesManager::get_payment_receipt(FullMessageId full_message_id,
@ -27190,7 +27190,7 @@ void MessagesManager::get_payment_receipt(FullMessageId full_message_id,
return promise.set_error(Status::Error(5, "Wrong message identifier")); return promise.set_error(Status::Error(5, "Wrong message identifier"));
} }
td::get_payment_receipt(message_id.get_server_message_id(), std::move(promise)); ::td::get_payment_receipt(message_id.get_server_message_id(), std::move(promise));
} }
void MessagesManager::on_get_sponsored_dialog_id(tl_object_ptr<telegram_api::Peer> peer, void MessagesManager::on_get_sponsored_dialog_id(tl_object_ptr<telegram_api::Peer> peer,

View File

@ -181,7 +181,7 @@ Result<Secret> Secret::create(Slice secret) {
return Status::Error(PSLICE() << "Wrong checksum " << checksum); return Status::Error(PSLICE() << "Wrong checksum " << checksum);
} }
UInt256 res; UInt256 res;
td::as_slice(res).copy_from(secret); ::td::as_slice(res).copy_from(secret);
UInt256 secret_sha256; UInt256 secret_sha256;
sha256(secret, ::td::as_slice(secret_sha256)); sha256(secret, ::td::as_slice(secret_sha256));
@ -191,7 +191,7 @@ Result<Secret> Secret::create(Slice secret) {
Secret Secret::create_new() { Secret Secret::create_new() {
UInt256 secret; UInt256 secret;
auto secret_slice = td::as_slice(secret); auto secret_slice = ::td::as_slice(secret);
Random::secure_bytes(secret_slice); Random::secure_bytes(secret_slice);
auto checksum_diff = secret_checksum(secret_slice); auto checksum_diff = secret_checksum(secret_slice);
uint8 new_byte = static_cast<uint8>((static_cast<uint32>(secret_slice.ubegin()[0]) + checksum_diff) % 255); uint8 new_byte = static_cast<uint8>((static_cast<uint32>(secret_slice.ubegin()[0]) + checksum_diff) % 255);
@ -200,8 +200,7 @@ Secret Secret::create_new() {
} }
Slice Secret::as_slice() const { Slice Secret::as_slice() const {
using td::as_slice; return ::td::as_slice(secret_);
return as_slice(secret_);
} }
int64 Secret::get_hash() const { int64 Secret::get_hash() const {
@ -226,8 +225,8 @@ EncryptedSecret Secret::encrypt(Slice key, Slice salt, EnryptionAlgorithm algori
}(); }();
UInt256 res; UInt256 res;
aes_cbc_state.encrypt(as_slice(), td::as_slice(res)); aes_cbc_state.encrypt(as_slice(), ::td::as_slice(res));
return EncryptedSecret::create(td::as_slice(res)).move_as_ok(); return EncryptedSecret::create(::td::as_slice(res)).move_as_ok();
} }
Secret::Secret(UInt256 secret, int64 hash) : secret_(secret), hash_(hash) { Secret::Secret(UInt256 secret, int64 hash) : secret_(secret), hash_(hash) {
@ -238,7 +237,7 @@ Result<EncryptedSecret> EncryptedSecret::create(Slice encrypted_secret) {
return Status::Error("Wrong encrypted secret size"); return Status::Error("Wrong encrypted secret size");
} }
UInt256 res; UInt256 res;
td::as_slice(res).copy_from(encrypted_secret); ::td::as_slice(res).copy_from(encrypted_secret);
return EncryptedSecret{res}; return EncryptedSecret{res};
} }
@ -256,12 +255,12 @@ Result<Secret> EncryptedSecret::decrypt(Slice key, Slice salt, EnryptionAlgorith
}(); }();
UInt256 res; UInt256 res;
aes_cbc_state.decrypt(td::as_slice(encrypted_secret_), td::as_slice(res)); aes_cbc_state.decrypt(::td::as_slice(encrypted_secret_), ::td::as_slice(res));
return Secret::create(td::as_slice(res)); return Secret::create(::td::as_slice(res));
} }
Slice EncryptedSecret::as_slice() const { Slice EncryptedSecret::as_slice() const {
return td::as_slice(encrypted_secret_); return ::td::as_slice(encrypted_secret_);
} }
EncryptedSecret::EncryptedSecret(UInt256 encrypted_secret) : encrypted_secret_(encrypted_secret) { EncryptedSecret::EncryptedSecret(UInt256 encrypted_secret) : encrypted_secret_(encrypted_secret) {

View File

@ -55,7 +55,7 @@ class ValueHash {
} }
static Result<ValueHash> create(Slice data); static Result<ValueHash> create(Slice data);
Slice as_slice() const { Slice as_slice() const {
return td::as_slice(hash_); return ::td::as_slice(hash_);
} }
private: private:

View File

@ -485,7 +485,7 @@ void TdDb::with_db_path(std::function<void(CSlice)> callback) {
} }
Result<string> TdDb::get_stats() { Result<string> TdDb::get_stats() {
auto sb = td::StringBuilder({}, true); auto sb = StringBuilder({}, true);
auto &sql = sql_connection_->get(); auto &sql = sql_connection_->get();
auto run_query = [&](CSlice query, Slice desc) -> Status { auto run_query = [&](CSlice query, Slice desc) -> Status {
TRY_RESULT(stmt, sql.get_statement(query)); TRY_RESULT(stmt, sql.get_statement(query));

View File

@ -677,7 +677,7 @@ void UpdatesManager::on_get_updates(tl_object_ptr<telegram_api::Updates> &&updat
auto update = move_tl_object_as<telegram_api::updateShort>(updates_ptr); auto update = move_tl_object_as<telegram_api::updateShort>(updates_ptr);
LOG(DEBUG) << "Receive " << oneline(to_string(update)); LOG(DEBUG) << "Receive " << oneline(to_string(update));
if (!is_acceptable_update(update->update_.get())) { if (!is_acceptable_update(update->update_.get())) {
LOG(ERROR) << "Receive unacceptable short update: " << td::oneline(to_string(update)); LOG(ERROR) << "Receive unacceptable short update: " << oneline(to_string(update));
return get_difference("unacceptable short update"); return get_difference("unacceptable short update");
} }
short_update_date_ = update->date_; short_update_date_ = update->date_;

View File

@ -77,14 +77,14 @@ static void dump_memory_usage() {
int cnt = 0; int cnt = 0;
for (auto &info : v) { for (auto &info : v) {
if (cnt++ < 50) { if (cnt++ < 50) {
LOG(WARNING) << td::format::as_size(info.size) << td::format::as_array(info.backtrace); LOG(WARNING) << format::as_size(info.size) << format::as_array(info.backtrace);
} else { } else {
other_size += info.size; other_size += info.size;
} }
total_size += info.size; total_size += info.size;
} }
LOG(WARNING) << tag("other", td::format::as_size(other_size)); LOG(WARNING) << tag("other", format::as_size(other_size));
LOG(WARNING) << tag("total", td::format::as_size(total_size)); LOG(WARNING) << tag("total", format::as_size(total_size));
LOG(WARNING) << tag("total traces", get_ht_size()); LOG(WARNING) << tag("total traces", get_ht_size());
LOG(WARNING) << tag("fast_backtrace_success_rate", get_fast_backtrace_success_rate()); LOG(WARNING) << tag("fast_backtrace_success_rate", get_fast_backtrace_success_rate());
} }
@ -301,7 +301,7 @@ class CliClient final : public Actor {
for (auto &m : messages.messages_) { for (auto &m : messages.messages_) {
// LOG(PLAIN) << to_string(m); // LOG(PLAIN) << to_string(m);
if (m->content_->get_id() == td_api::messageText::ID) { if (m->content_->get_id() == td_api::messageText::ID) {
LOG(PLAIN) << td::oneline(static_cast<const td_api::messageText *>(m->content_.get())->text_->text_) << "\n"; LOG(PLAIN) << oneline(static_cast<const td_api::messageText *>(m->content_.get())->text_->text_) << "\n";
} }
last_message_id = m->id_; last_message_id = m->id_;
} }
@ -3674,11 +3674,11 @@ class CliClient final : public Actor {
fd.seek(size).ignore(); fd.seek(size).ignore();
fd.truncate_to_current_position(size).ignore(); fd.truncate_to_current_position(size).ignore();
} else if (op == "SetVerbosity" || op == "SV") { } else if (op == "SetVerbosity" || op == "SV") {
td::Log::set_verbosity_level(to_integer<int>(args)); Log::set_verbosity_level(to_integer<int>(args));
} else if (op[0] == 'v' && op[1] == 'v') { } else if (op[0] == 'v' && op[1] == 'v') {
td::Log::set_verbosity_level(static_cast<int>(op.size())); Log::set_verbosity_level(static_cast<int>(op.size()));
} else if (op[0] == 'v' && ('0' <= op[1] && op[1] <= '9')) { } else if (op[0] == 'v' && ('0' <= op[1] && op[1] <= '9')) {
td::Log::set_verbosity_level(to_integer<int>(op.substr(1))); Log::set_verbosity_level(to_integer<int>(op.substr(1)));
} else if (op == "slse") { } else if (op == "slse") {
execute(td_api::make_object<td_api::setLogStream>(td_api::make_object<td_api::logStreamEmpty>())); execute(td_api::make_object<td_api::setLogStream>(td_api::make_object<td_api::logStreamEmpty>()));
} else if (op == "slsd") { } else if (op == "slsd") {
@ -3884,7 +3884,7 @@ void main(int argc, char **argv) {
ignore_signal(SignalType::Pipe).ensure(); ignore_signal(SignalType::Pipe).ensure();
set_signal_handler(SignalType::Error, fail_signal).ensure(); set_signal_handler(SignalType::Error, fail_signal).ensure();
set_signal_handler(SignalType::Abort, fail_signal).ensure(); set_signal_handler(SignalType::Abort, fail_signal).ensure();
td::Log::set_fatal_error_callback(on_fatal_error); Log::set_fatal_error_callback(on_fatal_error);
const char *locale_name = (std::setlocale(LC_ALL, "fr-FR") == nullptr ? "" : "fr-FR"); const char *locale_name = (std::setlocale(LC_ALL, "fr-FR") == nullptr ? "" : "fr-FR");
std::locale new_locale(locale_name); std::locale new_locale(locale_name);
@ -3898,8 +3898,8 @@ void main(int argc, char **argv) {
CliLog cli_log; CliLog cli_log;
log_interface = &cli_log; log_interface = &cli_log;
td::FileLog file_log; FileLog file_log;
td::TsLog ts_log(&file_log); TsLog ts_log(&file_log);
int new_verbosity_level = VERBOSITY_NAME(INFO); int new_verbosity_level = VERBOSITY_NAME(INFO);
bool use_test_dc = false; bool use_test_dc = false;
@ -3907,7 +3907,7 @@ void main(int argc, char **argv) {
bool disable_network = false; bool disable_network = false;
auto api_id = [](auto x) -> int32 { auto api_id = [](auto x) -> int32 {
if (x) { if (x) {
return td::to_integer<int32>(Slice(x)); return to_integer<int32>(Slice(x));
} }
return 0; return 0;
}(std::getenv("TD_API_ID")); }(std::getenv("TD_API_ID"));
@ -3951,7 +3951,7 @@ void main(int argc, char **argv) {
if (i + 1 >= argc) { if (i + 1 >= argc) {
return usage(); return usage();
} }
api_id = td::to_integer<int32>(Slice(argv[++i])); api_id = to_integer<int32>(Slice(argv[++i]));
} else if (!std::strcmp(argv[i], "--api_hash") || !std::strcmp(argv[i], "--api-hash")) { } else if (!std::strcmp(argv[i], "--api_hash") || !std::strcmp(argv[i], "--api-hash")) {
if (i + 1 >= argc) { if (i + 1 >= argc) {
return usage(); return usage();
@ -4005,7 +4005,7 @@ void main(int argc, char **argv) {
.release(); .release();
scheduler.start(); scheduler.start();
while (scheduler.run_main(td::Timestamp::in(100))) { while (scheduler.run_main(Timestamp::in(100))) {
} }
scheduler.finish(); scheduler.finish();
} }

View File

@ -37,7 +37,7 @@ Bitmask Bitmask::compress(int k) const {
std::string Bitmask::encode(int32 prefix_count) { std::string Bitmask::encode(int32 prefix_count) {
// remove zeroes in the end to make encoding deterministic // remove zeroes in the end to make encoding deterministic
td::Slice data(data_); Slice data(data_);
int save_i = -1; int save_i = -1;
char save_c; char save_c;

View File

@ -2620,7 +2620,7 @@ string FileManager::get_persistent_id(const FullRemoteFileLocation &location) {
auto binary = serialize(location_copy); auto binary = serialize(location_copy);
binary = zero_encode(binary); binary = zero_encode(binary);
binary.push_back(static_cast<char>(narrow_cast<td::uint8>(Version::Next) - 1)); binary.push_back(static_cast<char>(narrow_cast<uint8>(Version::Next) - 1));
binary.push_back(PERSISTENT_ID_VERSION); binary.push_back(PERSISTENT_ID_VERSION);
return base64url_encode(binary); return base64url_encode(binary);
} }

View File

@ -106,34 +106,34 @@ void scan_fs(CancellationToken &token, CallbackT &&callback) {
continue; continue;
} }
auto files_dir = get_files_dir(file_type); auto files_dir = get_files_dir(file_type);
td::walk_path(files_dir, walk_path(files_dir,
[&](CSlice path, WalkPath::Type type) { [&](CSlice path, WalkPath::Type type) {
if (token) { if (token) {
return WalkPath::Action::Abort; return WalkPath::Action::Abort;
} }
if (type != WalkPath::Type::NotDir) { if (type != WalkPath::Type::NotDir) {
return WalkPath::Action::Continue; return WalkPath::Action::Continue;
} }
auto r_stat = stat(path); auto r_stat = stat(path);
if (r_stat.is_error()) { if (r_stat.is_error()) {
LOG(WARNING) << "Stat in files gc failed: " << r_stat.error(); LOG(WARNING) << "Stat in files gc failed: " << r_stat.error();
return WalkPath::Action::Continue; return WalkPath::Action::Continue;
} }
auto stat = r_stat.move_as_ok(); auto stat = r_stat.move_as_ok();
if (ends_with(path, "/.nomedia") && stat.size_ == 0) { if (ends_with(path, "/.nomedia") && stat.size_ == 0) {
// skip .nomedia file // skip .nomedia file
return WalkPath::Action::Continue; return WalkPath::Action::Continue;
} }
FsFileInfo info; FsFileInfo info;
info.path = path.str(); info.path = path.str();
info.size = stat.size_; info.size = stat.size_;
info.file_type = file_type; info.file_type = file_type;
info.atime_nsec = stat.atime_nsec_; info.atime_nsec = stat.atime_nsec_;
info.mtime_nsec = stat.mtime_nsec_; info.mtime_nsec = stat.mtime_nsec_;
callback(info); callback(info);
return WalkPath::Action::Continue; return WalkPath::Action::Continue;
}) })
.ignore(); .ignore();
} }
} }

View File

@ -663,7 +663,7 @@ Result<mtproto::TransportType> ConnectionCreator::get_transport_type(const Proxy
CHECK(info.option != nullptr); CHECK(info.option != nullptr);
string proxy_authorization; string proxy_authorization;
if (!proxy.user().empty() || !proxy.password().empty()) { if (!proxy.user().empty() || !proxy.password().empty()) {
proxy_authorization = "|basic " + td::base64_encode(PSLICE() << proxy.user() << ':' << proxy.password()); proxy_authorization = "|basic " + base64_encode(PSLICE() << proxy.user() << ':' << proxy.password());
} }
return mtproto::TransportType{ return mtproto::TransportType{
mtproto::TransportType::Http, 0, mtproto::TransportType::Http, 0,

View File

@ -77,10 +77,10 @@ void dump_pending_network_queries() {
was_gap = false; was_gap = false;
} }
auto nq = &static_cast<NetQuery &>(*cur); auto nq = &static_cast<NetQuery &>(*cur);
LOG(WARNING) << tag("id", nq->my_id_) << *nq << tag("total_flood", td::format::as_time(nq->total_timeout)) << " " LOG(WARNING) << tag("id", nq->my_id_) << *nq << tag("total_flood", format::as_time(nq->total_timeout)) << " "
<< tag("since start", td::format::as_time(td::Time::now_cached() - nq->start_timestamp_)) << tag("since start", format::as_time(Time::now_cached() - nq->start_timestamp_))
<< tag("state", nq->debug_str_) << tag("state", nq->debug_str_)
<< tag("since state", td::format::as_time(td::Time::now_cached() - nq->debug_timestamp_)) << tag("since state", format::as_time(Time::now_cached() - nq->debug_timestamp_))
<< tag("resend_cnt", nq->debug_resend_cnt_) << tag("fail_cnt", nq->debug_send_failed_cnt_) << tag("resend_cnt", nq->debug_resend_cnt_) << tag("fail_cnt", nq->debug_send_failed_cnt_)
<< tag("ack", nq->debug_ack) << tag("unknown", nq->debug_unknown); << tag("ack", nq->debug_ack) << tag("unknown", nq->debug_unknown);
} else { } else {

View File

@ -80,7 +80,7 @@ void ConcurrentScheduler::start() {
auto &sched = schedulers_[i]; auto &sched = schedulers_[i];
threads_.push_back(td::thread([&]() { threads_.push_back(td::thread([&]() {
#if TD_PORT_WINDOWS #if TD_PORT_WINDOWS
td::detail::Iocp::Guard iocp_guard(iocp_.get()); detail::Iocp::Guard iocp_guard(iocp_.get());
#endif #endif
while (!is_finished()) { while (!is_finished()) {
sched->run(Timestamp::in(10)); sched->run(Timestamp::in(10));
@ -105,7 +105,7 @@ bool ConcurrentScheduler::run_main(Timestamp timeout) {
auto &main_sched = schedulers_[0]; auto &main_sched = schedulers_[0];
if (!is_finished()) { if (!is_finished()) {
#if TD_PORT_WINDOWS #if TD_PORT_WINDOWS
td::detail::Iocp::Guard iocp_guard(iocp_.get()); detail::Iocp::Guard iocp_guard(iocp_.get());
#endif #endif
main_sched->run(timeout); main_sched->run(timeout);
} }
@ -137,7 +137,7 @@ void ConcurrentScheduler::finish() {
SCOPE_EXIT { SCOPE_EXIT {
iocp_->clear(); iocp_->clear();
}; };
td::detail::Iocp::Guard iocp_guard(iocp_.get()); detail::Iocp::Guard iocp_guard(iocp_.get());
#endif #endif
#if !TD_THREAD_UNSUPPORTED && !TD_EVENTFD_UNSUPPORTED #if !TD_THREAD_UNSUPPORTED && !TD_EVENTFD_UNSUPPORTED

View File

@ -24,7 +24,7 @@ void HttpProxy::send_connect() {
string proxy_authorization; string proxy_authorization;
if (!username_.empty() || !password_.empty()) { if (!username_.empty() || !password_.empty()) {
auto userinfo = PSTRING() << username_ << ':' << password_; auto userinfo = PSTRING() << username_ << ':' << password_;
proxy_authorization = PSTRING() << "Proxy-Authorization: basic " << td::base64_encode(userinfo) << "\r\n"; proxy_authorization = PSTRING() << "Proxy-Authorization: basic " << base64_encode(userinfo) << "\r\n";
} }
fd_.output_buffer().append(PSLICE() << "CONNECT " << host << " HTTP/1.1\r\n" fd_.output_buffer().append(PSLICE() << "CONNECT " << host << " HTTP/1.1\r\n"
<< "Host: " << host << "\r\n" << "Host: " << host << "\r\n"

View File

@ -180,7 +180,7 @@ class DecTree {
} }
} }
void insert(KeyType key, ValueType value) { void insert(KeyType key, ValueType value) {
root_ = insert_node(std::move(root_), std::move(key), std::move(value), td::Random::fast_uint32()); root_ = insert_node(std::move(root_), std::move(key), std::move(value), Random::fast_uint32());
} }
void remove(const KeyType &key) { void remove(const KeyType &key) {
root_ = remove_node(std::move(root_), key); root_ = remove_node(std::move(root_), key);
@ -195,7 +195,7 @@ class DecTree {
if (size() == 0) { if (size() == 0) {
return nullptr; return nullptr;
} else { } else {
return get_node_by_idx(root_, td::Random::fast_uint32() % size()); return get_node_by_idx(root_, Random::fast_uint32() % size());
} }
} }
const ValueType *get(const KeyType &key) const { const ValueType *get(const KeyType &key) const {
@ -205,7 +205,7 @@ class DecTree {
if (size() == 0) { if (size() == 0) {
return nullptr; return nullptr;
} else { } else {
return get_node_by_idx(root_, td::Random::fast_uint32() % size()); return get_node_by_idx(root_, Random::fast_uint32() % size());
} }
} }
bool exists(const KeyType &key) const { bool exists(const KeyType &key) const {

View File

@ -154,7 +154,7 @@ class MpscLinkQueueUniquePtrNode {
MpscLinkQueueImpl::Node *to_mpsc_link_queue_node() { MpscLinkQueueImpl::Node *to_mpsc_link_queue_node() {
return ptr_.release()->to_mpsc_link_queue_node(); return ptr_.release()->to_mpsc_link_queue_node();
} }
static MpscLinkQueueUniquePtrNode<Value> from_mpsc_link_queue_node(td::MpscLinkQueueImpl::Node *node) { static MpscLinkQueueUniquePtrNode<Value> from_mpsc_link_queue_node(MpscLinkQueueImpl::Node *node) {
return MpscLinkQueueUniquePtrNode<Value>(unique_ptr<Value>(Value::from_mpsc_link_queue_node(node))); return MpscLinkQueueUniquePtrNode<Value>(unique_ptr<Value>(Value::from_mpsc_link_queue_node(node)));
} }

View File

@ -55,7 +55,7 @@ class Timestamp {
return Timestamp{timeout}; return Timestamp{timeout};
} }
static Timestamp at_unix(double timeout) { static Timestamp at_unix(double timeout) {
return Timestamp{timeout - td::Clocks::system() + Time::now()}; return Timestamp{timeout - Clocks::system() + Time::now()};
} }
static Timestamp in(double timeout) { static Timestamp in(double timeout) {

View File

@ -22,7 +22,7 @@ namespace td {
template <int id> template <int id>
static FileFd &get_file_fd() { static FileFd &get_file_fd() {
static FileFd result = FileFd::from_native_fd(NativeFd(id, true)); static FileFd result = FileFd::from_native_fd(NativeFd(id, true));
static auto guard = td::ScopeExit() + [&] { result.move_as_native_fd().release(); }; static auto guard = ScopeExit() + [&] { result.move_as_native_fd().release(); };
return result; return result;
} }
@ -42,7 +42,7 @@ static FileFd &get_file_fd() {
static auto handle = GetStdHandle(id); static auto handle = GetStdHandle(id);
LOG_IF(FATAL, handle == INVALID_HANDLE_VALUE) << "Failed to GetStdHandle " << id; LOG_IF(FATAL, handle == INVALID_HANDLE_VALUE) << "Failed to GetStdHandle " << id;
static FileFd result = FileFd::from_native_fd(NativeFd(handle, true)); static FileFd result = FileFd::from_native_fd(NativeFd(handle, true));
static auto guard = td::ScopeExit() + [&] { result.move_as_native_fd().release(); }; static auto guard = ScopeExit() + [&] { result.move_as_native_fd().release(); };
#else #else
static FileFd result; static FileFd result;
#endif #endif
@ -67,7 +67,7 @@ class BufferedStdinImpl : public Iocp::Callback {
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
BufferedStdinImpl() : info_(NativeFd(GetStdHandle(STD_INPUT_HANDLE), true)) { BufferedStdinImpl() : info_(NativeFd(GetStdHandle(STD_INPUT_HANDLE), true)) {
iocp_ref_ = Iocp::get()->get_ref(); iocp_ref_ = Iocp::get()->get_ref();
read_thread_ = td::thread([this] { this->read_loop(); }); read_thread_ = thread([this] { this->read_loop(); });
} }
#else #else
BufferedStdinImpl() { BufferedStdinImpl() {
@ -107,7 +107,7 @@ class BufferedStdinImpl : public Iocp::Callback {
PollableFdInfo info_; PollableFdInfo info_;
ChainBufferWriter writer_; ChainBufferWriter writer_;
ChainBufferReader reader_ = writer_.extract_reader(); ChainBufferReader reader_ = writer_.extract_reader();
td::thread read_thread_; thread read_thread_;
std::atomic<bool> close_flag_{false}; std::atomic<bool> close_flag_{false};
IocpRef iocp_ref_; IocpRef iocp_ref_;
std::atomic<int> refcnt_{1}; std::atomic<int> refcnt_{1};
@ -130,7 +130,7 @@ class BufferedStdinImpl : public Iocp::Callback {
} }
} }
void on_iocp(Result<size_t> r_size, WSAOVERLAPPED *overlapped) override { void on_iocp(Result<size_t> r_size, WSAOVERLAPPED *overlapped) override {
info_.add_flags_from_poll(td::PollFlags::Read()); info_.add_flags_from_poll(PollFlags::Read());
dec_refcnt(); dec_refcnt();
} }

View File

@ -289,7 +289,7 @@ void signal_safe_write_pointer(void *p, bool add_header) {
char *ptr = end; char *ptr = end;
*--ptr = '\n'; *--ptr = '\n';
do { do {
*--ptr = td::format::hex_digit(addr % 16); *--ptr = format::hex_digit(addr % 16);
addr /= 16; addr /= 16;
} while (addr != 0); } while (addr != 0);
*--ptr = 'x'; *--ptr = 'x';