Minor improvements.

This commit is contained in:
levlam 2022-10-12 15:59:58 +03:00
parent 0b29caaac1
commit ee28a37906
40 changed files with 70 additions and 26 deletions

View File

@ -10,6 +10,7 @@
#include "td/telegram/CallId.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/UserId.h"
#include "td/actor/actor.h"

View File

@ -24,6 +24,7 @@
#include "td/utils/misc.h"
#include "td/utils/Slice.h"
#include "td/utils/SliceBuilder.h"
#include "td/utils/Status.h"
#include "td/utils/tl_helpers.h"
#include <algorithm>

View File

@ -14,8 +14,11 @@
#include "td/utils/algorithm.h"
#include "td/utils/buffer.h"
#include "td/utils/logging.h"
#include "td/utils/Status.h"
#include <limits>
namespace td {
struct EmojiStatuses {

View File

@ -6,12 +6,16 @@
//
#include "td/telegram/InputInvoice.h"
#include "td/telegram/Dimensions.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/files/FileType.h"
#include "td/telegram/misc.h"
#include "td/telegram/PhotoSize.h"
#include "td/telegram/ServerMessageId.h"
#include "td/telegram/Td.h"
#include "td/utils/algorithm.h"
#include "td/utils/buffer.h"
#include "td/utils/common.h"
#include "td/utils/HttpUrl.h"
#include "td/utils/logging.h"

View File

@ -6,6 +6,7 @@
//
#pragma once
#include "td/telegram/DialogId.h"
#include "td/telegram/files/FileId.h"
#include "td/telegram/LabeledPricePart.h"
#include "td/telegram/MessageExtendedMedia.h"

View File

@ -9,10 +9,13 @@
#include "td/telegram/Document.h"
#include "td/telegram/DocumentsManager.h"
#include "td/telegram/MessageContent.h"
#include "td/telegram/MessageContentType.h"
#include "td/telegram/PhotoSize.h"
#include "td/telegram/Td.h"
#include "td/telegram/VideosManager.h"
#include "td/utils/algorithm.h"
#include "td/utils/logging.h"
namespace td {

View File

@ -6,12 +6,16 @@
//
#pragma once
#include "td/telegram/DialogId.h"
#include "td/telegram/Dimensions.h"
#include "td/telegram/files/FileId.h"
#include "td/telegram/MessageEntity.h"
#include "td/telegram/Photo.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/utils/common.h"
#include "td/utils/Status.h"
namespace td {

View File

@ -11,6 +11,7 @@
#include "td/telegram/Td.h"
#include "td/telegram/VideosManager.h"
#include "td/utils/logging.h"
#include "td/utils/tl_helpers.h"
namespace td {

View File

@ -30,6 +30,8 @@
#include "td/utils/emoji.h"
#include "td/utils/FlatHashSet.h"
#include "td/utils/logging.h"
#include "td/utils/Slice.h"
#include "td/utils/SliceBuilder.h"
#include "td/utils/Status.h"
#include "td/utils/utf8.h"

View File

@ -7,6 +7,7 @@
#include "td/telegram/MessagesDb.h"
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/UserId.h"
#include "td/telegram/Version.h"
#include "td/db/SqliteConnectionSafe.h"

View File

@ -19,6 +19,7 @@
#include "td/telegram/NotificationType.h"
#include "td/telegram/Photo.h"
#include "td/telegram/td_api.h"
#include "td/telegram/UserId.h"
#include "td/actor/actor.h"
#include "td/actor/MultiTimeout.h"

View File

@ -10,6 +10,7 @@
#include "td/telegram/telegram_api.h"
#include "td/utils/common.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
#include "td/utils/StringBuilder.h"

View File

@ -12,14 +12,17 @@
#include "td/telegram/Global.h"
#include "td/telegram/InputInvoice.h"
#include "td/telegram/MessageEntity.h"
#include "td/telegram/MessageId.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/misc.h"
#include "td/telegram/PasswordManager.h"
#include "td/telegram/Photo.h"
#include "td/telegram/ServerMessageId.h"
#include "td/telegram/Td.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/ThemeManager.h"
#include "td/telegram/UpdatesManager.h"
#include "td/telegram/UserId.h"
#include "td/utils/algorithm.h"
#include "td/utils/buffer.h"

View File

@ -15,9 +15,11 @@
#include "td/telegram/Global.h"
#include "td/telegram/MessageEntity.h"
#include "td/telegram/misc.h"
#include "td/telegram/PremiumGiftOption.h"
#include "td/telegram/Td.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/UpdatesManager.h"
#include "td/telegram/UserId.h"
#include "td/utils/algorithm.h"
#include "td/utils/buffer.h"

View File

@ -6,6 +6,8 @@
//
#include "td/telegram/SentEmailCode.h"
#include "td/utils/logging.h"
namespace td {
SentEmailCode::SentEmailCode(telegram_api::object_ptr<telegram_api::account_sentEmailCode> &&email_code)

View File

@ -18,6 +18,7 @@
#include "td/telegram/ServerMessageId.h"
#include "td/telegram/Td.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/UserId.h"
#include "td/utils/algorithm.h"
#include "td/utils/buffer.h"

View File

@ -21,6 +21,7 @@
#include "td/telegram/StickerType.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/UserId.h"
#include "td/actor/actor.h"
#include "td/actor/MultiPromise.h"
@ -37,6 +38,7 @@
#include "td/utils/WaitFreeHashMap.h"
#include "td/utils/WaitFreeHashSet.h"
#include <map>
#include <memory>
#include <tuple>
#include <unordered_map>

View File

@ -7,9 +7,11 @@
#include "td/telegram/Support.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessageEntity.h"
#include "td/telegram/Td.h"
#include "td/telegram/telegram_api.h"
#include "td/utils/buffer.h"
#include "td/utils/Status.h"

View File

@ -42,6 +42,7 @@
#include "td/telegram/DocumentsManager.h"
#include "td/telegram/DownloadManager.h"
#include "td/telegram/DownloadManagerCallback.h"
#include "td/telegram/EmailVerification.h"
#include "td/telegram/EmojiStatus.h"
#include "td/telegram/FileReferenceManager.h"
#include "td/telegram/files/FileGcParameters.h"
@ -121,6 +122,7 @@
#include "td/telegram/TopDialogCategory.h"
#include "td/telegram/TopDialogManager.h"
#include "td/telegram/UpdatesManager.h"
#include "td/telegram/UserId.h"
#include "td/telegram/Version.h"
#include "td/telegram/VideoNotesManager.h"
#include "td/telegram/VideosManager.h"

View File

@ -10,6 +10,7 @@
#include "td/telegram/BackgroundManager.h"
#include "td/telegram/BackgroundType.hpp"
#include "td/telegram/Global.h"
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/net/NetQueryCreator.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"

View File

@ -22,6 +22,7 @@
#include "td/utils/FlatHashMap.h"
#include "td/utils/FlatHashSet.h"
#include "td/utils/Promise.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
#include "td/utils/WaitFreeHashMap.h"

View File

@ -17,6 +17,7 @@
#include "td/telegram/Td.h"
#include "td/telegram/Version.h"
#include "td/utils/algorithm.h"
#include "td/utils/common.h"
#include "td/utils/misc.h"
#include "td/utils/tl_helpers.h"

View File

@ -38,10 +38,10 @@ class FileDbInterface {
FileDbInterface &operator=(const FileDbInterface &) = delete;
virtual ~FileDbInterface() = default;
// non thread safe
// non-thread-safe
virtual FileDbId create_pmc_id() = 0;
// thread safe
// thread-safe
virtual void close(Promise<> promise) = 0;
template <class LocationT>

View File

@ -33,8 +33,8 @@
namespace td {
FileDownloader::FileDownloader(const FullRemoteFileLocation &remote, const LocalFileLocation &local, int64 size,
string name, const FileEncryptionKey &encryption_key, bool is_small, bool search_file,
int64 offset, int64 limit, unique_ptr<Callback> callback)
string name, const FileEncryptionKey &encryption_key, bool is_small,
bool need_search_file, int64 offset, int64 limit, unique_ptr<Callback> callback)
: remote_(remote)
, local_(local)
, size_(size)
@ -42,7 +42,7 @@ FileDownloader::FileDownloader(const FullRemoteFileLocation &remote, const Local
, encryption_key_(encryption_key)
, callback_(std::move(callback))
, is_small_(is_small)
, search_file_(search_file)
, need_search_file_(need_search_file)
, offset_(offset)
, limit_(limit) {
if (encryption_key.is_secret()) {
@ -87,7 +87,7 @@ Result<FileLoader::FileInfo> FileDownloader::init() {
CHECK((part_size & (part_size - 1)) == 0);
}
}
if (search_file_ && fd_.empty() && size_ > 0 && encryption_key_.empty() && !remote_.is_web()) {
if (need_search_file_ && fd_.empty() && size_ > 0 && encryption_key_.empty() && !remote_.is_web()) {
[&] {
TRY_RESULT(path, search_file(remote_.file_type_, name_, size_));
TRY_RESULT(fd, FileFd::open(path, FileFd::Read));

View File

@ -33,8 +33,8 @@ class FileDownloader final : public FileLoader {
};
FileDownloader(const FullRemoteFileLocation &remote, const LocalFileLocation &local, int64 size, string name,
const FileEncryptionKey &encryption_key, bool is_small, bool search_file, int64 offset, int64 limit,
unique_ptr<Callback> callback);
const FileEncryptionKey &encryption_key, bool is_small, bool need_search_file, int64 offset,
int64 limit, unique_ptr<Callback> callback);
// Should just implement all parent pure virtual methods.
// Must not call any of them...
@ -55,7 +55,7 @@ class FileDownloader final : public FileLoader {
int32 next_part_ = 0;
bool next_part_stop_ = false;
bool is_small_;
bool search_file_{false};
bool need_search_file_{false};
int64 offset_;
int64 limit_;

View File

@ -21,6 +21,7 @@
#include "td/utils/Random.h"
#include "td/utils/SliceBuilder.h"
#include "td/utils/StringBuilder.h"
#include "td/utils/utf8.h"
#include <tuple>

View File

@ -32,7 +32,6 @@
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/PathView.h"
#include "td/utils/port/path.h"
#include "td/utils/port/Stat.h"
#include "td/utils/ScopeGuard.h"
#include "td/utils/SliceBuilder.h"
@ -40,7 +39,6 @@
#include "td/utils/Time.h"
#include "td/utils/tl_helpers.h"
#include "td/utils/tl_parsers.h"
#include "td/utils/utf8.h"
#include <algorithm>
#include <cmath>

View File

@ -11,6 +11,7 @@
#include "td/telegram/files/FileEncryptionKey.h"
#include "td/telegram/files/FileGenerateManager.h"
#include "td/telegram/files/FileId.h"
#include "td/telegram/files/FileLoaderUtils.h"
#include "td/telegram/files/FileLoadManager.h"
#include "td/telegram/files/FileLocation.h"
#include "td/telegram/files/FileSourceId.h"

View File

@ -70,7 +70,7 @@ void ConcurrentScheduler::test_one_thread_run() {
} while (!is_finished_.load(std::memory_order_relaxed));
}
thread::id ConcurrentScheduler::get_thread_id(int32 sched_id) {
thread::id ConcurrentScheduler::get_scheduler_thread_id(int32 sched_id) {
auto thread_pos = static_cast<size_t>(sched_id - 1);
CHECK(thread_pos < threads_.size());
return threads_[thread_pos].get_id();

View File

@ -50,7 +50,7 @@ class ConcurrentScheduler final : private Scheduler::Callback {
return is_finished_.load(std::memory_order_relaxed);
}
thread::id get_thread_id(int32 sched_id);
thread::id get_scheduler_thread_id(int32 sched_id);
void start();

View File

@ -68,7 +68,7 @@ class TsSeqKeyValue {
return kv_.get_all();
}
// not thread safe method
// non-thread-safe method
SeqKeyValue &inner() {
return kv_;
}

View File

@ -51,13 +51,13 @@ bool HttpChunkedByteFlow::loop() {
return false;
}
total_size_ += ready;
uncommited_size_ += ready;
uncommitted_size_ += ready;
output_.append(input_->cut_head(ready));
result = true;
len_ -= ready;
if (uncommited_size_ >= MIN_UPDATE_SIZE) {
uncommited_size_ = 0;
if (uncommitted_size_ >= MIN_UPDATE_SIZE) {
uncommitted_size_ = 0;
}
if (len_ == 0) {

View File

@ -25,7 +25,7 @@ class HttpChunkedByteFlow final : public ByteFlowBase {
size_t len_ = 0;
size_t save_len_ = 0;
size_t total_size_ = 0;
size_t uncommited_size_ = 0;
size_t uncommitted_size_ = 0;
};
} // namespace td

View File

@ -35,7 +35,7 @@ bool GzipByteFlow::loop() {
auto r_state = gzip_.run();
auto output_size = gzip_.flush_output();
if (output_size) {
uncommited_size_ += output_size;
uncommitted_size_ += output_size;
total_output_size_ += output_size;
if (total_output_size_ > max_output_size_) {
finish(Status::Error("Max output size limit exceeded"));

View File

@ -38,7 +38,7 @@ class GzipByteFlow final : public ByteFlowBase {
private:
Gzip gzip_;
size_t uncommited_size_ = 0;
size_t uncommitted_size_ = 0;
size_t total_output_size_ = 0;
size_t max_output_size_ = std::numeric_limits<size_t>::max();
};

View File

@ -88,8 +88,8 @@ class HazardPointers {
size_t to_delete_size_unsafe() const {
size_t res = 0;
for (auto &thread : threads_) {
res += thread.to_delete_.size();
for (auto &thread_data : threads_) {
res += thread_data.to_delete_.size();
}
return res;
}
@ -122,8 +122,8 @@ class HazardPointers {
}
bool is_protected(T *ptr) {
for (auto &thread : threads_) {
for (auto &hazard_ptr : thread.hazard_) {
for (auto &thread_data : threads_) {
for (auto &hazard_ptr : thread_data.hazard_) {
if (hazard_ptr.load() == ptr) {
return true;
}

View File

@ -214,7 +214,7 @@ class SharedObjectPool {
return free_queue_reader_.calc_size();
}
//non thread safe
// non-thread-safe
template <class F>
void for_each(F &&f) {
for (auto &raw : allocated_) {
@ -255,7 +255,7 @@ class SharedObjectPool {
Raw *get() const {
return raw_;
}
explicit operator bool() noexcept {
explicit operator bool() const noexcept {
return raw_ != nullptr;
}

View File

@ -10,6 +10,7 @@
#include "td/utils/BigNum.h"
#include "td/utils/bits.h"
#include "td/utils/common.h"
#include "td/utils/Destructor.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/port/RwMutex.h"

View File

@ -10,6 +10,7 @@
#include "td/telegram/td_api.h"
#include "td/utils/common.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/tests.h"

View File

@ -7,11 +7,13 @@
#include "td/telegram/EncryptedFile.h"
#include "td/telegram/FolderId.h"
#include "td/telegram/Global.h"
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/MessageId.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/SecretChatActor.h"
#include "td/telegram/SecretChatId.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/UserId.h"
#include "td/db/binlog/BinlogInterface.h"
#include "td/db/binlog/detail/BinlogEventsProcessor.h"