Replace std::max/min with td::max/min.
GitOrigin-RevId: 56fb21194e995cbb37b3ebb5caed689c10320b8d
This commit is contained in:
parent
24c873884f
commit
a6ab35e616
@ -125,8 +125,7 @@ Status AuthData::check_packet(int64 session_id, int64 message_id, double now, bo
|
||||
// Client is to check that the session_id field in the decrypted message indeed equals to that of an active session
|
||||
// created by the client.
|
||||
if (get_session_id() != static_cast<uint64>(session_id)) {
|
||||
return Status::Error(PSLICE() << "Got packet from different session "
|
||||
<< tag("current session_id", get_session_id())
|
||||
return Status::Error(PSLICE() << "Got packet from different session " << tag("current session_id", get_session_id())
|
||||
<< tag("got session_id", session_id));
|
||||
}
|
||||
|
||||
|
@ -796,8 +796,8 @@ void SessionConnection::flush_packet() {
|
||||
if (mode_ == Mode::HttpLongPoll) {
|
||||
max_delay = HTTP_MAX_DELAY;
|
||||
max_after = HTTP_MAX_AFTER;
|
||||
max_wait = std::min(http_max_wait(), static_cast<int>(1000 * std::max(0.1, ping_disconnect_delay() + last_pong_at_ -
|
||||
Time::now_cached() - 1)));
|
||||
max_wait = min(http_max_wait(),
|
||||
static_cast<int>(1000 * max(0.1, ping_disconnect_delay() + last_pong_at_ - Time::now_cached() - 1)));
|
||||
} else if (mode_ == Mode::Http) {
|
||||
max_delay = HTTP_MAX_DELAY;
|
||||
max_after = HTTP_MAX_AFTER;
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "td/utils/StringBuilder.h"
|
||||
#include "td/utils/tl_parsers.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
@ -127,7 +126,7 @@ class SessionConnection
|
||||
bool online_flag_ = false;
|
||||
|
||||
int rtt() const {
|
||||
return std::max(2, static_cast<int>(raw_connection_->rtt_ * 1.5));
|
||||
return max(2, static_cast<int>(raw_connection_->rtt_ * 1.5));
|
||||
}
|
||||
|
||||
int32 ping_disconnect_delay() const {
|
||||
|
@ -249,7 +249,7 @@ void AnimationsManager::create_animation(FileId file_id, PhotoSize thumbnail, st
|
||||
a->file_id = file_id;
|
||||
a->file_name = std::move(file_name);
|
||||
a->mime_type = std::move(mime_type);
|
||||
a->duration = std::max(duration, 0);
|
||||
a->duration = max(duration, 0);
|
||||
a->dimensions = dimensions;
|
||||
a->thumbnail = std::move(thumbnail);
|
||||
on_get_animation(std::move(a), replace);
|
||||
|
@ -21,8 +21,6 @@
|
||||
#include "td/utils/misc.h"
|
||||
#include "td/utils/Status.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace td {
|
||||
|
||||
AudiosManager::AudiosManager(Td *td) : td_(td) {
|
||||
@ -176,7 +174,7 @@ void AudiosManager::create_audio(FileId file_id, PhotoSize thumbnail, string fil
|
||||
a->file_id = file_id;
|
||||
a->file_name = std::move(file_name);
|
||||
a->mime_type = std::move(mime_type);
|
||||
a->duration = std::max(duration, 0);
|
||||
a->duration = max(duration, 0);
|
||||
a->title = std::move(title);
|
||||
a->performer = std::move(performer);
|
||||
a->thumbnail = std::move(thumbnail);
|
||||
|
@ -24,8 +24,6 @@
|
||||
#include "td/utils/ScopeGuard.h"
|
||||
#include "td/utils/Time.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace td {
|
||||
|
||||
// SendCodeHelper
|
||||
@ -43,9 +41,9 @@ td_api::object_ptr<td_api::authorizationStateWaitCode> SendCodeHelper::get_autho
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::authenticationCodeInfo> SendCodeHelper::get_authentication_code_info_object() const {
|
||||
return make_tl_object<td_api::authenticationCodeInfo>(
|
||||
get_authentication_code_type_object(sent_code_info_), get_authentication_code_type_object(next_code_info_),
|
||||
std::max(next_code_timeout_ - static_cast<int32>(Time::now()), 0));
|
||||
return make_tl_object<td_api::authenticationCodeInfo>(get_authentication_code_type_object(sent_code_info_),
|
||||
get_authentication_code_type_object(next_code_info_),
|
||||
max(next_code_timeout_ - static_cast<int32>(Time::now()), 0));
|
||||
}
|
||||
|
||||
Result<telegram_api::auth_resendCode> SendCodeHelper::resend_code() {
|
||||
|
@ -16,8 +16,6 @@
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/Status.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace td {
|
||||
|
||||
Result<Client::Request> ClientJson::to_request(Slice request) {
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "td/utils/Time.h"
|
||||
#include "td/utils/tl_parsers.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
@ -646,7 +645,7 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
|
||||
bool is_from_main_dc = G()->net_query_dispatcher().main_dc_id().get_value() == config->this_dc_;
|
||||
|
||||
LOG(INFO) << to_string(config);
|
||||
auto reload_in = std::max(60 /* at least 60 seconds*/, config->expires_ - config->date_);
|
||||
auto reload_in = max(60 /* at least 60 seconds*/, config->expires_ - config->date_);
|
||||
save_config_expire(Timestamp::in(reload_in));
|
||||
reload_in -= Random::fast(0, reload_in / 5);
|
||||
if (!is_from_main_dc) {
|
||||
|
@ -2267,7 +2267,7 @@ ContactsManager::ContactsManager(Td *td, ActorShared<> parent) : td_(td), parent
|
||||
if (G()->parameters().use_chat_info_db) {
|
||||
auto next_contacts_sync_date_string = G()->td_db()->get_binlog_pmc()->get("next_contacts_sync_date");
|
||||
if (!next_contacts_sync_date_string.empty()) {
|
||||
next_contacts_sync_date_ = std::min(to_integer<int32>(next_contacts_sync_date_string), G()->unix_time() + 100000);
|
||||
next_contacts_sync_date_ = min(to_integer<int32>(next_contacts_sync_date_string), G()->unix_time() + 100000);
|
||||
}
|
||||
|
||||
auto saved_contact_count_string = G()->td_db()->get_binlog_pmc()->get("saved_contact_count");
|
||||
|
@ -21,8 +21,6 @@
|
||||
#include "td/utils/port/Clocks.h"
|
||||
#include "td/utils/tl_helpers.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace td {
|
||||
|
||||
Global::Global() = default;
|
||||
@ -64,8 +62,8 @@ void Global::set_mtproto_header(std::unique_ptr<MtprotoHeader> mtproto_header) {
|
||||
Status Global::init(const TdParameters ¶meters, ActorId<Td> td, std::unique_ptr<TdDb> td_db) {
|
||||
parameters_ = parameters;
|
||||
|
||||
gc_scheduler_id_ = std::min(Scheduler::instance()->sched_id() + 2, Scheduler::instance()->sched_count() - 1);
|
||||
slow_net_scheduler_id_ = std::min(Scheduler::instance()->sched_id() + 3, Scheduler::instance()->sched_count() - 1);
|
||||
gc_scheduler_id_ = min(Scheduler::instance()->sched_id() + 2, Scheduler::instance()->sched_count() - 1);
|
||||
slow_net_scheduler_id_ = min(Scheduler::instance()->sched_id() + 3, Scheduler::instance()->sched_count() - 1);
|
||||
|
||||
td_ = td;
|
||||
td_db_ = std::move(td_db);
|
||||
|
@ -11,8 +11,6 @@
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/Slice.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace td {
|
||||
|
||||
static FileLog file_log;
|
||||
@ -40,7 +38,7 @@ bool Log::set_file_path(string file_path) {
|
||||
}
|
||||
|
||||
void Log::set_max_file_size(int64 max_file_size) {
|
||||
max_log_file_size = std::max(max_file_size, static_cast<int64>(0));
|
||||
max_log_file_size = max(max_file_size, static_cast<int64>(0));
|
||||
file_log.set_rotate_threshold(max_log_file_size);
|
||||
}
|
||||
|
||||
|
@ -526,7 +526,7 @@ class GetDialogListQuery : public NetActorOnce {
|
||||
auto dialogs = move_tl_object_as<telegram_api::messages_dialogsSlice>(ptr);
|
||||
td->contacts_manager_->on_get_chats(std::move(dialogs->chats_));
|
||||
td->contacts_manager_->on_get_users(std::move(dialogs->users_));
|
||||
td->messages_manager_->on_get_dialogs(std::move(dialogs->dialogs_), std::max(dialogs->count_, 0),
|
||||
td->messages_manager_->on_get_dialogs(std::move(dialogs->dialogs_), max(dialogs->count_, 0),
|
||||
std::move(dialogs->messages_), std::move(promise));
|
||||
}
|
||||
}
|
||||
@ -3967,7 +3967,7 @@ void MessagesManager::Message::store(StorerT &storer) const {
|
||||
if (ttl_expires_at == 0) {
|
||||
store(-1.0, storer);
|
||||
} else {
|
||||
double ttl_left = std::max(ttl_expires_at - Time::now_cached(), 0.0);
|
||||
double ttl_left = max(ttl_expires_at - Time::now_cached(), 0.0);
|
||||
store(ttl_left, storer);
|
||||
store(server_time, storer);
|
||||
}
|
||||
@ -4079,8 +4079,8 @@ void MessagesManager::Message::parse(ParserT &parser) {
|
||||
} else {
|
||||
double old_server_time;
|
||||
parse(old_server_time, parser);
|
||||
double passed_server_time = std::max(parser.context()->server_time() - old_server_time, 0.0);
|
||||
ttl_left = std::max(ttl_left - passed_server_time, 0.0);
|
||||
double passed_server_time = max(parser.context()->server_time() - old_server_time, 0.0);
|
||||
ttl_left = max(ttl_left - passed_server_time, 0.0);
|
||||
ttl_expires_at = Time::now_cached() + ttl_left;
|
||||
}
|
||||
}
|
||||
@ -4514,7 +4514,7 @@ void MessagesManager::on_pending_message_views_timeout_callback(void *messages_m
|
||||
|
||||
const size_t MAX_MESSAGE_VIEWS = 100; // server side limit
|
||||
vector<MessageId> message_ids;
|
||||
message_ids.reserve(std::min(d->pending_viewed_message_ids.size(), MAX_MESSAGE_VIEWS));
|
||||
message_ids.reserve(min(d->pending_viewed_message_ids.size(), MAX_MESSAGE_VIEWS));
|
||||
for (auto message_id : d->pending_viewed_message_ids) {
|
||||
message_ids.push_back(message_id);
|
||||
if (message_ids.size() >= MAX_MESSAGE_VIEWS) {
|
||||
@ -9360,7 +9360,7 @@ std::pair<DialogId, unique_ptr<MessagesManager::Message>> MessagesManager::creat
|
||||
LOG(ERROR) << "Wrong ttl = " << ttl << " received in " << message_id << " in " << dialog_id;
|
||||
ttl = 0;
|
||||
} else if (ttl > 0) {
|
||||
ttl = std::max(ttl, get_message_content_duration(message_info.content.get()) + 1);
|
||||
ttl = max(ttl, get_message_content_duration(message_info.content.get()) + 1);
|
||||
}
|
||||
|
||||
int32 views = message_info.views;
|
||||
@ -10613,14 +10613,14 @@ void MessagesManager::on_get_dialogs_from_database(vector<BufferSlice> &&dialogs
|
||||
// if there is no more dialogs in the database
|
||||
last_loaded_database_dialog_date_ = MAX_DIALOG_DATE;
|
||||
LOG(INFO) << "Set last loaded database dialog date to " << last_loaded_database_dialog_date_;
|
||||
last_server_dialog_date_ = std::max(last_server_dialog_date_, last_database_server_dialog_date_);
|
||||
last_server_dialog_date_ = max(last_server_dialog_date_, last_database_server_dialog_date_);
|
||||
LOG(INFO) << "Set last server dialog date to " << last_server_dialog_date_;
|
||||
update_last_dialog_date();
|
||||
}
|
||||
if (last_loaded_database_dialog_date_ < max_dialog_date) {
|
||||
last_loaded_database_dialog_date_ = std::min(max_dialog_date, last_database_server_dialog_date_);
|
||||
last_loaded_database_dialog_date_ = min(max_dialog_date, last_database_server_dialog_date_);
|
||||
LOG(INFO) << "Set last loaded database dialog date to " << last_loaded_database_dialog_date_;
|
||||
last_server_dialog_date_ = std::max(last_server_dialog_date_, last_loaded_database_dialog_date_);
|
||||
last_server_dialog_date_ = max(last_server_dialog_date_, last_loaded_database_dialog_date_);
|
||||
LOG(INFO) << "Set last server dialog date to " << last_server_dialog_date_;
|
||||
update_last_dialog_date();
|
||||
} else if (!dialogs.empty()) {
|
||||
@ -10738,7 +10738,7 @@ std::pair<size_t, vector<DialogId>> MessagesManager::search_dialogs(const string
|
||||
}
|
||||
|
||||
promise.set_value(Unit());
|
||||
size_t result_size = std::min(static_cast<size_t>(limit), recently_found_dialog_ids_.size());
|
||||
size_t result_size = min(static_cast<size_t>(limit), recently_found_dialog_ids_.size());
|
||||
return {recently_found_dialog_ids_.size(),
|
||||
vector<DialogId>(recently_found_dialog_ids_.begin(), recently_found_dialog_ids_.begin() + result_size)};
|
||||
}
|
||||
@ -12165,7 +12165,7 @@ tl_object_ptr<td_api::NotificationSettingsScope> MessagesManager::get_notificati
|
||||
|
||||
tl_object_ptr<td_api::notificationSettings> MessagesManager::get_notification_settings_object(
|
||||
const NotificationSettings *notification_settings) {
|
||||
return make_tl_object<td_api::notificationSettings>(std::max(0, notification_settings->mute_until - G()->unix_time()),
|
||||
return make_tl_object<td_api::notificationSettings>(max(0, notification_settings->mute_until - G()->unix_time()),
|
||||
notification_settings->sound,
|
||||
notification_settings->show_preview);
|
||||
}
|
||||
@ -13597,11 +13597,11 @@ void MessagesManager::load_messages(DialogId dialog_id, MessageId from_message_i
|
||||
}
|
||||
if (offset >= -1) {
|
||||
// get history before some server or local message
|
||||
limit = std::min(std::max(limit + offset + 1, MAX_GET_HISTORY / 2), MAX_GET_HISTORY);
|
||||
limit = min(max(limit + offset + 1, MAX_GET_HISTORY / 2), MAX_GET_HISTORY);
|
||||
offset = -1;
|
||||
} else {
|
||||
// get history around some server or local message
|
||||
int32 messages_to_load = std::max(MAX_GET_HISTORY, limit);
|
||||
int32 messages_to_load = max(MAX_GET_HISTORY, limit);
|
||||
int32 max_add = messages_to_load - limit;
|
||||
offset -= max_add;
|
||||
limit = MAX_GET_HISTORY;
|
||||
@ -13668,7 +13668,7 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
|
||||
can_forward_message(dialog_id, message), can_delete_for_self, can_delete_for_all_users, message->is_channel_post,
|
||||
message->contains_unread_mention, message->date, message->edit_date,
|
||||
get_message_forward_info_object(message->forward_info), message->reply_to_message_id.get(), message->ttl,
|
||||
message->ttl_expires_at != 0 ? std::max(message->ttl_expires_at - Time::now(), 1e-3) : message->ttl,
|
||||
message->ttl_expires_at != 0 ? max(message->ttl_expires_at - Time::now(), 1e-3) : message->ttl,
|
||||
td_->contacts_manager_->get_user_id_object(message->via_bot_user_id, "via_bot_user_id"),
|
||||
message->author_signature, message->views, message->media_album_id,
|
||||
get_message_content_object(message->content.get()), get_reply_markup_object(message->reply_markup));
|
||||
@ -14439,7 +14439,7 @@ MessagesManager::Message *MessagesManager::get_message_to_send(Dialog *d, Messag
|
||||
m->ttl = 0;
|
||||
}
|
||||
if (m->ttl > 0) {
|
||||
m->ttl = std::max(m->ttl, get_message_content_duration(m->content.get()) + 1);
|
||||
m->ttl = max(m->ttl, get_message_content_duration(m->content.get()) + 1);
|
||||
}
|
||||
if (reply_to_message_id.is_valid()) {
|
||||
auto *reply_to_message = get_message_force(d, reply_to_message_id);
|
||||
@ -24333,6 +24333,4 @@ void MessagesManager::get_payment_receipt(FullMessageId full_message_id,
|
||||
td::get_payment_receipt(message_id.get_server_message_id(), std::move(promise));
|
||||
}
|
||||
|
||||
constexpr int32 MessagesManager::MAX_GET_HISTORY;
|
||||
|
||||
} // namespace td
|
||||
|
@ -1783,7 +1783,7 @@ vector<FileId> StickersManager::get_stickers(string emoji, int32 limit, bool for
|
||||
}
|
||||
|
||||
vector<FileId> sorted;
|
||||
sorted.reserve(std::min(limit_size_t, result.size()));
|
||||
sorted.reserve(min(limit_size_t, result.size()));
|
||||
for (auto &sticker_id : prepend_sticker_ids) {
|
||||
bool is_good = false;
|
||||
auto it = std::find(result.begin(), result.end(), sticker_id);
|
||||
|
@ -78,7 +78,6 @@
|
||||
#include "td/utils/tl_parsers.h"
|
||||
#include "td/utils/utf8.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
@ -4212,7 +4211,7 @@ Status Td::init(DbKey key) {
|
||||
|
||||
TdDb::Events events;
|
||||
TRY_RESULT(td_db,
|
||||
TdDb::open(std::min(current_scheduler_id + 1, scheduler_count - 1), parameters_, std::move(key), events));
|
||||
TdDb::open(min(current_scheduler_id + 1, scheduler_count - 1), parameters_, std::move(key), events));
|
||||
LOG(INFO) << "Successfully inited database in " << tag("database_directory", parameters_.database_directory)
|
||||
<< " and " << tag("files_directory", parameters_.files_directory);
|
||||
G()->init(parameters_, actor_id(this), std::move(td_db)).ensure();
|
||||
@ -4339,7 +4338,7 @@ Status Td::init(DbKey key) {
|
||||
secret_chats_manager_ = create_actor<SecretChatsManager>("SecretChatsManager", create_reference());
|
||||
G()->set_secret_chats_manager(secret_chats_manager_.get());
|
||||
storage_manager_ = create_actor<StorageManager>("StorageManager", create_reference(),
|
||||
std::min(current_scheduler_id + 2, scheduler_count - 1));
|
||||
min(current_scheduler_id + 2, scheduler_count - 1));
|
||||
G()->set_storage_manager(storage_manager_.get());
|
||||
top_dialog_manager_ = create_actor<TopDialogManager>("TopDialogManager", create_reference());
|
||||
G()->set_top_dialog_manager(top_dialog_manager_.get());
|
||||
@ -6313,7 +6312,7 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
|
||||
<< min << ", " << max << "]");
|
||||
return true;
|
||||
}
|
||||
G()->shared_config().set_option_integer(name, std::max(std::min(value, max), min));
|
||||
G()->shared_config().set_option_integer(name, clamp(value, min, max));
|
||||
}
|
||||
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
|
||||
return true;
|
||||
|
@ -33,8 +33,6 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
constexpr size_t TopDialogManager::MAX_TOP_DIALOGS_LIMIT;
|
||||
|
||||
static CSlice top_dialog_category_name(TopDialogCategory category) {
|
||||
switch (category) {
|
||||
case TopDialogCategory::Correspondent:
|
||||
@ -235,9 +233,9 @@ void TopDialogManager::do_get_top_dialogs(GetTopDialogsQuery &&query) {
|
||||
CHECK(pos < by_category_.size());
|
||||
auto &top_dialogs = by_category_[pos];
|
||||
|
||||
auto limit = std::min(query.limit, MAX_TOP_DIALOGS_LIMIT);
|
||||
auto limit = min(query.limit, MAX_TOP_DIALOGS_LIMIT);
|
||||
|
||||
limit = std::min(limit, top_dialogs.dialogs.size());
|
||||
limit = min(limit, top_dialogs.dialogs.size());
|
||||
vector<DialogId> dialog_ids = transform(top_dialogs.dialogs, [](const auto &x) { return x.dialog_id; });
|
||||
|
||||
auto promise = PromiseCreator::lambda([query = std::move(query), dialog_ids, limit](Result<Unit>) mutable {
|
||||
|
@ -21,8 +21,6 @@
|
||||
#include "td/utils/misc.h"
|
||||
#include "td/utils/Status.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace td {
|
||||
|
||||
VideoNotesManager::VideoNotesManager(Td *td) : td_(td) {
|
||||
@ -151,7 +149,7 @@ void VideoNotesManager::create_video_note(FileId file_id, PhotoSize thumbnail, i
|
||||
bool replace) {
|
||||
auto v = make_unique<VideoNote>();
|
||||
v->file_id = file_id;
|
||||
v->duration = std::max(duration, 0);
|
||||
v->duration = max(duration, 0);
|
||||
if (dimensions.width == dimensions.height && dimensions.width <= 640) {
|
||||
v->dimensions = dimensions;
|
||||
} else {
|
||||
|
@ -22,8 +22,6 @@
|
||||
#include "td/utils/misc.h"
|
||||
#include "td/utils/Status.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace td {
|
||||
|
||||
VideosManager::VideosManager(Td *td) : td_(td) {
|
||||
@ -182,7 +180,7 @@ void VideosManager::create_video(FileId file_id, PhotoSize thumbnail, bool has_s
|
||||
v->file_id = file_id;
|
||||
v->file_name = std::move(file_name);
|
||||
v->mime_type = std::move(mime_type);
|
||||
v->duration = std::max(duration, 0);
|
||||
v->duration = max(duration, 0);
|
||||
v->dimensions = dimensions;
|
||||
v->thumbnail = std::move(thumbnail);
|
||||
v->supports_streaming = supports_streaming;
|
||||
|
@ -22,8 +22,6 @@
|
||||
#include "td/utils/misc.h"
|
||||
#include "td/utils/Status.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace td {
|
||||
|
||||
VoiceNotesManager::VoiceNotesManager(Td *td) : td_(td) {
|
||||
@ -136,7 +134,7 @@ void VoiceNotesManager::create_voice_note(FileId file_id, string mime_type, int3
|
||||
auto v = std::make_unique<VoiceNote>();
|
||||
v->file_id = file_id;
|
||||
v->mime_type = std::move(mime_type);
|
||||
v->duration = std::max(duration, 0);
|
||||
v->duration = max(duration, 0);
|
||||
v->waveform = std::move(waveform);
|
||||
on_get_voice_note(std::move(v), replace);
|
||||
}
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include "td/utils/StringBuilder.h"
|
||||
#include "td/utils/tl_helpers.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
|
||||
namespace td {
|
||||
@ -544,7 +543,7 @@ class WebPagesManager::PageBlockAuthorDate : public PageBlock {
|
||||
|
||||
public:
|
||||
PageBlockAuthorDate() = default;
|
||||
PageBlockAuthorDate(RichText &&author, int32 date) : author(std::move(author)), date(std::max(date, 0)) {
|
||||
PageBlockAuthorDate(RichText &&author, int32 date) : author(std::move(author)), date(max(date, 0)) {
|
||||
}
|
||||
|
||||
Type get_type() const override {
|
||||
@ -1125,7 +1124,7 @@ class WebPagesManager::PageBlockEmbeddedPost : public PageBlock {
|
||||
: url(std::move(url))
|
||||
, author(std::move(author))
|
||||
, author_photo(std::move(author_photo))
|
||||
, date(std::max(date, 0))
|
||||
, date(max(date, 0))
|
||||
, page_blocks(std::move(page_blocks))
|
||||
, caption(std::move(caption)) {
|
||||
}
|
||||
@ -1439,7 +1438,7 @@ WebPageId WebPagesManager::on_get_web_page(tl_object_ptr<telegram_api::WebPage>
|
||||
auto web_page_date = web_page->date_;
|
||||
LOG(INFO) << "Got pending " << web_page_id << ", date = " << web_page_date << ", now = " << G()->server_time();
|
||||
|
||||
pending_web_pages_timeout_.add_timeout_in(web_page_id.get(), std::max(web_page_date - G()->server_time(), 1.0));
|
||||
pending_web_pages_timeout_.add_timeout_in(web_page_id.get(), max(web_page_date - G()->server_time(), 1.0));
|
||||
return web_page_id;
|
||||
}
|
||||
case telegram_api::webPage::ID: {
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "td/utils/ScopeGuard.h"
|
||||
#include "td/utils/Slice.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <tuple>
|
||||
|
||||
namespace td {
|
||||
@ -171,7 +170,7 @@ Result<std::pair<NetQueryPtr, bool>> FileDownloader::start_part(Part part, int32
|
||||
// auto size = part.size;
|
||||
//// sometimes we can ask more than server has, just to check size
|
||||
// if (size < get_part_size()) {
|
||||
// size = std::min(size + 16, get_part_size());
|
||||
// size = min(size + 16, get_part_size());
|
||||
// LOG(INFO) << "Ask " << size << " instead of " << part.size;
|
||||
//}
|
||||
auto size = get_part_size();
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "td/utils/misc.h"
|
||||
#include "td/utils/ScopeGuard.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <tuple>
|
||||
|
||||
namespace td {
|
||||
@ -73,7 +72,7 @@ void FileLoader::start_up() {
|
||||
}
|
||||
auto file_info = r_file_info.ok();
|
||||
auto size = file_info.size;
|
||||
auto expected_size = std::max(size, file_info.expected_size);
|
||||
auto expected_size = max(size, file_info.expected_size);
|
||||
bool is_size_final = file_info.is_size_final;
|
||||
auto part_size = file_info.part_size;
|
||||
auto &ready_parts = file_info.ready_parts;
|
||||
|
@ -164,7 +164,7 @@ void FileNode::set_generate_priority(int8 download_priority, int8 upload_priorit
|
||||
<< upload_priority;
|
||||
on_info_changed();
|
||||
}
|
||||
generate_priority_ = std::max(download_priority, upload_priority);
|
||||
generate_priority_ = max(download_priority, upload_priority);
|
||||
generate_download_priority_ = download_priority;
|
||||
generate_upload_priority_ = upload_priority;
|
||||
}
|
||||
@ -282,8 +282,7 @@ int64 FileView::local_total_size() const {
|
||||
case LocalFileLocation::Type::Full:
|
||||
return node_->size_;
|
||||
case LocalFileLocation::Type::Partial:
|
||||
return std::max(
|
||||
static_cast<int64>(node_->local_.partial().part_size_) * node_->local_.partial().ready_part_count_,
|
||||
return max(static_cast<int64>(node_->local_.partial().part_size_) * node_->local_.partial().ready_part_count_,
|
||||
node_->local_ready_size_);
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -301,7 +300,7 @@ int64 FileView::remote_size() const {
|
||||
return node_->size_;
|
||||
case RemoteFileLocation::Type::Partial: {
|
||||
auto res =
|
||||
std::max(static_cast<int64>(node_->remote_.partial().part_size_) * node_->remote_.partial().ready_part_count_,
|
||||
max(static_cast<int64>(node_->remote_.partial().part_size_) * node_->remote_.partial().ready_part_count_,
|
||||
node_->remote_ready_size_);
|
||||
if (size() != 0 && size() < res) {
|
||||
res = size();
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/misc.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <numeric>
|
||||
|
||||
@ -53,8 +52,8 @@ Status PartsManager::init_no_size(size_t part_size, const std::vector<int> &read
|
||||
if (known_prefix_flag_) {
|
||||
part_count_ = static_cast<int>(known_prefix_size_ / part_size_);
|
||||
}
|
||||
part_count_ = std::max(part_count_, std::accumulate(ready_parts.begin(), ready_parts.end(), 0,
|
||||
[](auto a, auto b) { return std::max(a, b + 1); }));
|
||||
part_count_ = max(part_count_, std::accumulate(ready_parts.begin(), ready_parts.end(), 0,
|
||||
[](auto a, auto b) { return max(a, b + 1); }));
|
||||
|
||||
init_common(ready_parts);
|
||||
return Status::OK();
|
||||
@ -169,7 +168,7 @@ Status PartsManager::set_known_prefix(size_t size, bool is_ready) {
|
||||
CHECK(known_prefix_flag_);
|
||||
CHECK(size >= static_cast<size_t>(known_prefix_size_));
|
||||
known_prefix_size_ = narrow_cast<int64>(size);
|
||||
expected_size_ = std::max(known_prefix_size_, expected_size_);
|
||||
expected_size_ = max(known_prefix_size_, expected_size_);
|
||||
|
||||
CHECK(static_cast<size_t>(part_count_) == part_status_.size());
|
||||
if (is_ready) {
|
||||
@ -203,10 +202,10 @@ Status PartsManager::on_part_ok(int32 id, size_t part_size, size_t actual_size)
|
||||
if (unknown_size_flag_) {
|
||||
CHECK(part_size == part_size_);
|
||||
if (actual_size < part_size_) {
|
||||
max_size_ = std::min(max_size_, end_offset);
|
||||
max_size_ = min(max_size_, end_offset);
|
||||
}
|
||||
if (actual_size) {
|
||||
min_size_ = std::max(min_size_, end_offset);
|
||||
min_size_ = max(min_size_, end_offset);
|
||||
}
|
||||
if (min_size_ > max_size_) {
|
||||
auto status = Status::Error(PSLICE() << "Failed to transfer file: " << tag("min_size", min_size_)
|
||||
@ -251,7 +250,7 @@ int64 PartsManager::get_ready_size() const {
|
||||
|
||||
int64 PartsManager::get_expected_size() const {
|
||||
if (unknown_size_flag_) {
|
||||
return std::max(static_cast<int64>(512 * (1 << 10)), get_ready_size() * 2);
|
||||
return max(static_cast<int64>(512 * (1 << 10)), get_ready_size() * 2);
|
||||
}
|
||||
return get_size();
|
||||
}
|
||||
@ -302,7 +301,7 @@ int64 PartsManager::get_unchecked_ready_prefix_size() {
|
||||
int64 res = part.offset;
|
||||
if (!unknown_size_flag_) {
|
||||
res += narrow_cast<int64>(part.size);
|
||||
res = std::min(res, get_size());
|
||||
res = min(res, get_size());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -315,7 +314,7 @@ Part PartsManager::get_part(int id) {
|
||||
if (total_size < offset) {
|
||||
size = 0;
|
||||
} else {
|
||||
size = std::min(size, total_size - offset);
|
||||
size = min(size, total_size - offset);
|
||||
}
|
||||
}
|
||||
return Part{id, offset, static_cast<size_t>(size)};
|
||||
|
@ -111,7 +111,7 @@ bool ResourceManager::satisfy_node(NodeId file_node_id) {
|
||||
return true;
|
||||
}
|
||||
auto give = resource_state_.unused();
|
||||
give = std::min(need, give);
|
||||
give = min(need, give);
|
||||
give -= give % part_size;
|
||||
VLOG(files) << tag("give", give);
|
||||
if (give == 0) {
|
||||
|
@ -11,8 +11,6 @@
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/StringBuilder.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace td {
|
||||
|
||||
class ResourceState {
|
||||
@ -58,7 +56,7 @@ class ResourceState {
|
||||
}
|
||||
|
||||
int64 estimated_extra() const {
|
||||
auto new_unused = std::max(limit_, estimated_limit_) - using_ - used_;
|
||||
auto new_unused = max(limit_, estimated_limit_) - using_ - used_;
|
||||
new_unused = static_cast<int64>((new_unused + unit_size() - 1) / unit_size() * unit_size());
|
||||
return new_unused + using_ + used_ - limit_;
|
||||
}
|
||||
|
@ -352,9 +352,9 @@ void ConnectionCreator::client_loop(ClientInfo &client) {
|
||||
|
||||
// Check flood
|
||||
auto &flood_control = online_flag_ ? client.flood_control_online : client.flood_control;
|
||||
auto wakeup_at = std::max(flood_control.get_wakeup_at(), client.mtproto_error_flood_control.get_wakeup_at());
|
||||
auto wakeup_at = max(flood_control.get_wakeup_at(), client.mtproto_error_flood_control.get_wakeup_at());
|
||||
if (!online_flag_) {
|
||||
wakeup_at = std::max(wakeup_at, client.backoff.get_wakeup_at());
|
||||
wakeup_at = max(wakeup_at, client.backoff.get_wakeup_at());
|
||||
}
|
||||
if (wakeup_at > Time::now()) {
|
||||
return client_set_timeout_at(client, wakeup_at);
|
||||
@ -691,6 +691,4 @@ void ConnectionCreator::on_proxy_resolved(Result<IPAddress> r_ip_address, bool d
|
||||
}
|
||||
}
|
||||
|
||||
constexpr int32 ConnectionCreator::ClientInfo::Backoff::MAX_BACKOFF;
|
||||
|
||||
} // namespace td
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "td/utils/Status.h"
|
||||
#include "td/utils/Time.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
@ -161,7 +160,7 @@ class ConnectionCreator : public Actor {
|
||||
public:
|
||||
void add_event(int32 now) {
|
||||
wakeup_at_ = now + next_delay_;
|
||||
next_delay_ = std::min(MAX_BACKOFF, next_delay_ * 2);
|
||||
next_delay_ = min(MAX_BACKOFF, next_delay_ * 2);
|
||||
}
|
||||
int32 get_wakeup_at() const {
|
||||
return wakeup_at_;
|
||||
|
@ -25,8 +25,6 @@
|
||||
#include "td/utils/port/thread.h"
|
||||
#include "td/utils/Slice.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace td {
|
||||
void NetQueryDispatcher::dispatch(NetQueryPtr net_query) {
|
||||
net_query->debug("dispatch");
|
||||
@ -231,7 +229,7 @@ bool NetQueryDispatcher::is_dc_inited(int32 raw_dc_id) {
|
||||
return dcs_[raw_dc_id - 1].is_valid_.load(std::memory_order_relaxed);
|
||||
}
|
||||
int32 NetQueryDispatcher::get_session_count() {
|
||||
return std::max(G()->shared_config().get_option_integer("session_count"), 1);
|
||||
return max(G()->shared_config().get_option_integer("session_count"), 1);
|
||||
}
|
||||
|
||||
bool NetQueryDispatcher::get_use_pfs() {
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/Time.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
|
||||
namespace td {
|
||||
@ -89,7 +88,7 @@ class TempAuthKeyWatchdog : public NetQueryCallback {
|
||||
sync_at_ = now + SYNC_WAIT_MAX;
|
||||
}
|
||||
LOG(DEBUG) << "set timeout";
|
||||
set_timeout_at(std::min(sync_at_, now + SYNC_WAIT));
|
||||
set_timeout_at(min(sync_at_, now + SYNC_WAIT));
|
||||
}
|
||||
|
||||
void timeout_expired() override {
|
||||
|
@ -24,8 +24,6 @@
|
||||
#include "td/utils/tl_helpers.h"
|
||||
#include "td/utils/tl_parsers.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace td {
|
||||
namespace detail {
|
||||
struct AesCtrEncryptionEvent {
|
||||
@ -465,7 +463,7 @@ Status Binlog::load_binlog(const Callback &callback, const Callback &debug_callb
|
||||
if (ready_flag) {
|
||||
break;
|
||||
}
|
||||
TRY_STATUS(fd_.flush_read(std::max(need_size, static_cast<size_t>(4096))));
|
||||
TRY_STATUS(fd_.flush_read(max(need_size, static_cast<size_t>(4096))));
|
||||
buffer_reader_.sync_with_writer();
|
||||
if (byte_flow_flag_) {
|
||||
byte_flow_source_.wakeup();
|
||||
|
@ -12,9 +12,8 @@
|
||||
#include "td/utils/misc.h"
|
||||
#include "td/utils/Status.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace td {
|
||||
|
||||
void HttpChunkedByteFlow::loop() {
|
||||
bool was_updated = false;
|
||||
size_t need_size;
|
||||
@ -40,8 +39,8 @@ void HttpChunkedByteFlow::loop() {
|
||||
}
|
||||
|
||||
auto size = input_->size();
|
||||
auto ready = std::min(len_, size);
|
||||
need_size = std::min(MIN_UPDATE_SIZE, len_ + 2);
|
||||
auto ready = min(len_, size);
|
||||
need_size = min(MIN_UPDATE_SIZE, len_ + 2);
|
||||
if (size < need_size) {
|
||||
break;
|
||||
}
|
||||
@ -80,5 +79,5 @@ void HttpChunkedByteFlow::loop() {
|
||||
}
|
||||
set_need_size(need_size);
|
||||
}
|
||||
constexpr size_t HttpChunkedByteFlow::MIN_UPDATE_SIZE;
|
||||
|
||||
} // namespace td
|
||||
|
@ -8,8 +8,6 @@
|
||||
|
||||
#include "td/utils/Status.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace td {
|
||||
|
||||
void HttpContentLengthByteFlow::loop() {
|
||||
@ -17,7 +15,7 @@ void HttpContentLengthByteFlow::loop() {
|
||||
if (ready_size > len_) {
|
||||
ready_size = len_;
|
||||
}
|
||||
auto need_size = std::min(MIN_UPDATE_SIZE, len_);
|
||||
auto need_size = min(MIN_UPDATE_SIZE, len_);
|
||||
if (ready_size < need_size) {
|
||||
set_need_size(need_size);
|
||||
return;
|
||||
@ -32,6 +30,5 @@ void HttpContentLengthByteFlow::loop() {
|
||||
}
|
||||
on_output_updated();
|
||||
}
|
||||
constexpr size_t HttpContentLengthByteFlow::MIN_UPDATE_SIZE;
|
||||
|
||||
} // namespace td
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "td/utils/Slice.h"
|
||||
#include "td/utils/Status.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
namespace td {
|
||||
@ -54,7 +53,7 @@ inline Result<size_t> BufferedReader::read(MutableSlice slice) {
|
||||
begin_pos_ = 0;
|
||||
end_pos_ = result;
|
||||
|
||||
size_t left = std::min(end_pos_, slice.size());
|
||||
size_t left = min(end_pos_, slice.size());
|
||||
std::memcpy(slice.begin(), &buff_[begin_pos_], left);
|
||||
begin_pos_ += left;
|
||||
return left + available;
|
||||
|
@ -9,8 +9,6 @@
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/TimedStat.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace td {
|
||||
|
||||
class FloodControlFast {
|
||||
@ -19,7 +17,7 @@ class FloodControlFast {
|
||||
for (auto &limit : limits_) {
|
||||
limit.stat_.add_event(CounterStat::Event(), now);
|
||||
if (limit.stat_.get_stat(now).count_ > limit.count_) {
|
||||
wakeup_at_ = std::max(wakeup_at_, now + limit.duration_ * 2);
|
||||
wakeup_at_ = max(wakeup_at_, now + limit.duration_ * 2);
|
||||
}
|
||||
}
|
||||
return wakeup_at_;
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/logging.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
namespace td {
|
||||
@ -62,13 +61,13 @@ class FloodControlStrict {
|
||||
|
||||
if (limit.count_ + limit.pos_ <= events_.size()) {
|
||||
CHECK(limit.count_ + limit.pos_ == events_.size());
|
||||
wakeup_at_ = std::max(wakeup_at_, events_[limit.pos_].timestamp_ + limit.duration_);
|
||||
wakeup_at_ = max(wakeup_at_, events_[limit.pos_].timestamp_ + limit.duration_);
|
||||
without_update_ = 0;
|
||||
} else {
|
||||
without_update_ = std::min(without_update_, limit.count_ + limit.pos_ - events_.size());
|
||||
without_update_ = min(without_update_, limit.count_ + limit.pos_ - events_.size());
|
||||
}
|
||||
|
||||
min_pos = std::min(min_pos, limit.pos_);
|
||||
min_pos = min(min_pos, limit.pos_);
|
||||
}
|
||||
|
||||
if (min_pos * 2 > events_.size()) {
|
||||
|
@ -9,8 +9,6 @@
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/logging.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace td {
|
||||
|
||||
struct HeapNode {
|
||||
@ -119,7 +117,7 @@ class KHeap {
|
||||
auto item = array_[pos];
|
||||
while (true) {
|
||||
int left_pos = pos * K + 1;
|
||||
int right_pos = std::min(left_pos + K, static_cast<int>(array_.size()));
|
||||
int right_pos = min(left_pos + K, static_cast<int>(array_.size()));
|
||||
int next_pos = pos;
|
||||
KeyT next_key = item.key_;
|
||||
for (int i = left_pos; i < right_pos; i++) {
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include <openssl/rand.h>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <random>
|
||||
@ -33,7 +32,7 @@ void Random::secure_bytes(unsigned char *ptr, size_t size) {
|
||||
buf_pos = buf_size;
|
||||
}
|
||||
|
||||
auto ready = std::min(size, buf_size - buf_pos);
|
||||
auto ready = min(size, buf_size - buf_pos);
|
||||
if (ready != 0) {
|
||||
std::memcpy(ptr, buf + buf_pos, ready);
|
||||
buf_pos += ready;
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
namespace td {
|
||||
@ -96,7 +95,7 @@ inline MutableSlice MutableSlice::substr(size_t from) const {
|
||||
}
|
||||
inline MutableSlice MutableSlice::substr(size_t from, size_t size) const {
|
||||
CHECK(from <= len_);
|
||||
return MutableSlice(s_ + from, std::min(size, len_ - from));
|
||||
return MutableSlice(s_ + from, min(size, len_ - from));
|
||||
}
|
||||
|
||||
inline size_t MutableSlice::find(char c) const {
|
||||
@ -217,7 +216,7 @@ inline Slice Slice::substr(size_t from) const {
|
||||
}
|
||||
inline Slice Slice::substr(size_t from, size_t size) const {
|
||||
CHECK(from <= len_);
|
||||
return Slice(s_ + from, std::min(size, len_ - from));
|
||||
return Slice(s_ + from, min(size, len_ - from));
|
||||
}
|
||||
|
||||
inline size_t Slice::find(char c) const {
|
||||
|
@ -23,7 +23,7 @@ string base64_encode(Slice input) {
|
||||
string base64;
|
||||
base64.reserve((input.size() + 2) / 3 * 4);
|
||||
for (size_t i = 0; i < input.size();) {
|
||||
size_t left = std::min(input.size() - i, static_cast<size_t>(3));
|
||||
size_t left = min(input.size() - i, static_cast<size_t>(3));
|
||||
int c = input.ubegin()[i++] << 16;
|
||||
base64 += symbols64[c >> 18];
|
||||
if (left != 1) {
|
||||
@ -78,7 +78,7 @@ Result<string> base64_decode(Slice base64) {
|
||||
string output;
|
||||
output.reserve(((base64.size() + 3) >> 2) * 3);
|
||||
for (size_t i = 0; i < base64.size();) {
|
||||
size_t left = std::min(base64.size() - i, static_cast<size_t>(4));
|
||||
size_t left = min(base64.size() - i, static_cast<size_t>(4));
|
||||
int c = 0;
|
||||
for (size_t t = 0; t < left; t++) {
|
||||
auto value = char_to_value[base64.ubegin()[i++]];
|
||||
@ -112,7 +112,7 @@ string base64url_encode(Slice input) {
|
||||
string base64;
|
||||
base64.reserve((input.size() + 2) / 3 * 4);
|
||||
for (size_t i = 0; i < input.size();) {
|
||||
size_t left = std::min(input.size() - i, static_cast<size_t>(3));
|
||||
size_t left = min(input.size() - i, static_cast<size_t>(3));
|
||||
int c = input.ubegin()[i++] << 16;
|
||||
base64 += url_symbols64[c >> 18];
|
||||
if (left != 1) {
|
||||
@ -163,7 +163,7 @@ Result<string> base64url_decode(Slice base64) {
|
||||
string output;
|
||||
output.reserve(((base64.size() + 3) >> 2) * 3);
|
||||
for (size_t i = 0; i < base64.size();) {
|
||||
size_t left = std::min(base64.size() - i, static_cast<size_t>(4));
|
||||
size_t left = min(base64.size() - i, static_cast<size_t>(4));
|
||||
int c = 0;
|
||||
for (size_t t = 0; t < left; t++) {
|
||||
auto value = url_char_to_value[base64.ubegin()[i++]];
|
||||
|
@ -76,7 +76,7 @@ BufferAllocator::ReaderPtr BufferAllocator::create_reader(const ReaderPtr &raw)
|
||||
void BufferAllocator::dec_ref_cnt(BufferRaw *ptr) {
|
||||
int left = ptr->ref_cnt_.fetch_sub(1, std::memory_order_acq_rel);
|
||||
if (left == 1) {
|
||||
auto buf_size = std::max(sizeof(BufferRaw), offsetof(BufferRaw, data_) + ptr->data_size_);
|
||||
auto buf_size = max(sizeof(BufferRaw), offsetof(BufferRaw, data_) + ptr->data_size_);
|
||||
buffer_mem -= buf_size;
|
||||
ptr->~BufferRaw();
|
||||
delete[] ptr;
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "td/utils/port/thread_local.h"
|
||||
#include "td/utils/Slice.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
@ -470,7 +469,7 @@ class ChainBufferIterator {
|
||||
skipped += ready.size();
|
||||
|
||||
// copy to dest if possible
|
||||
auto to_dest_size = std::min(ready.size(), dest.size());
|
||||
auto to_dest_size = min(ready.size(), dest.size());
|
||||
if (to_dest_size != 0) {
|
||||
std::memcpy(dest.data(), ready.data(), to_dest_size);
|
||||
dest.remove_prefix(to_dest_size);
|
||||
@ -588,7 +587,7 @@ class ChainBufferReader {
|
||||
}
|
||||
|
||||
BufferSlice read_as_buffer_slice(size_t limit = std::numeric_limits<size_t>::max()) {
|
||||
return begin_.read_as_buffer_slice(std::min(limit, size()));
|
||||
return begin_.read_as_buffer_slice(min(limit, size()));
|
||||
}
|
||||
|
||||
private:
|
||||
@ -649,7 +648,7 @@ class ChainBufferWriter {
|
||||
void append(Slice slice) {
|
||||
while (!slice.empty()) {
|
||||
auto ready = prepare_append(slice.size());
|
||||
auto shift = std::min(ready.size(), slice.size());
|
||||
auto shift = min(ready.size(), slice.size());
|
||||
std::memcpy(ready.data(), slice.data(), shift);
|
||||
confirm_append(shift);
|
||||
slice.remove_prefix(shift);
|
||||
|
@ -82,6 +82,18 @@ inline bool unlikely(bool x) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// replace std::max and std::min to not have to include <algorithm> everywhere
|
||||
// as a side bonus, accept parameters by value, so constexpr variables aren't required to be instantiated
|
||||
template <class T>
|
||||
T max(T a, T b) {
|
||||
return a < b ? b : a;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T min(T a, T b) {
|
||||
return a > b ? b : a;
|
||||
}
|
||||
|
||||
using string = std::string;
|
||||
|
||||
template <class ValueT>
|
||||
|
@ -73,7 +73,7 @@ uint64 pq_factorize(uint64 pq) {
|
||||
uint64 q = Random::fast(17, 32) % (pq - 1);
|
||||
uint64 x = Random::fast_uint64() % (pq - 1) + 1;
|
||||
uint64 y = x;
|
||||
int lim = 1 << (std::min(5, i) + 18);
|
||||
int lim = 1 << (min(5, i) + 18);
|
||||
for (int j = 1; j < lim; j++) {
|
||||
it++;
|
||||
uint64 a = x;
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/misc.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#endif
|
||||
@ -555,7 +554,7 @@ class Fd::FdImpl {
|
||||
}
|
||||
Result<size_t> read_async(MutableSlice slice) TD_WARN_UNUSED_RESULT {
|
||||
CHECK(async_mode_);
|
||||
auto res = input_reader_.advance(std::min(slice.size(), input_reader_.size()), slice);
|
||||
auto res = input_reader_.advance(min(slice.size(), input_reader_.size()), slice);
|
||||
if (res == 0) {
|
||||
clear_flags(Fd::Flag::Read);
|
||||
}
|
||||
|
Reference in New Issue
Block a user