diff --git a/benchmark/bench_crypto.cpp b/benchmark/bench_crypto.cpp index b6d36c237..f915fbcf9 100644 --- a/benchmark/bench_crypto.cpp +++ b/benchmark/bench_crypto.cpp @@ -17,10 +17,12 @@ #include #include +#include #include #include #include #include +#include #include #include #include @@ -38,10 +40,7 @@ class SHA1Bench final : public td::Benchmark { } void start_up() final { - for (int i = 0; i < DATA_SIZE; i++) { - data[i] = 123; - data[i] = 0; - } + std::fill(std::begin(data), std::end(data), static_cast(123)); } void run(int n) final { @@ -64,9 +63,7 @@ class AesEcbBench final : public td::Benchmark { } void start_up() final { - for (int i = 0; i < DATA_SIZE; i++) { - data[i] = 123; - } + std::fill(std::begin(data), std::end(data), static_cast(123)); td::Random::secure_bytes(key.raw, sizeof(key)); td::Random::secure_bytes(iv.raw, sizeof(iv)); } @@ -95,9 +92,7 @@ class AesIgeEncryptBench final : public td::Benchmark { } void start_up() final { - for (int i = 0; i < DATA_SIZE; i++) { - data[i] = 123; - } + std::fill(std::begin(data), std::end(data), static_cast(123)); td::Random::secure_bytes(key.raw, sizeof(key)); td::Random::secure_bytes(iv.raw, sizeof(iv)); } @@ -123,9 +118,7 @@ class AesIgeDecryptBench final : public td::Benchmark { } void start_up() final { - for (int i = 0; i < DATA_SIZE; i++) { - data[i] = 123; - } + std::fill(std::begin(data), std::end(data), static_cast(123)); td::Random::secure_bytes(key.raw, sizeof(key)); td::Random::secure_bytes(iv.raw, sizeof(iv)); } @@ -151,9 +144,7 @@ class AesCtrBench final : public td::Benchmark { } void start_up() final { - for (int i = 0; i < DATA_SIZE; i++) { - data[i] = 123; - } + std::fill(std::begin(data), std::end(data), static_cast(123)); td::Random::secure_bytes(key.raw, sizeof(key)); td::Random::secure_bytes(iv.raw, sizeof(iv)); } @@ -180,9 +171,7 @@ class AesCtrOpenSSLBench final : public td::Benchmark { } void start_up() final { - for (int i = 0; i < DATA_SIZE; i++) { - data[i] = 123; - } + std::fill(std::begin(data), std::end(data), static_cast(123)); td::Random::secure_bytes(key.raw, sizeof(key)); td::Random::secure_bytes(iv.raw, sizeof(iv)); } @@ -216,9 +205,7 @@ class AesCbcDecryptBench final : public td::Benchmark { } void start_up() final { - for (int i = 0; i < DATA_SIZE; i++) { - data[i] = 123; - } + std::fill(std::begin(data), std::end(data), static_cast(123)); td::Random::secure_bytes(as_slice(key)); td::Random::secure_bytes(as_slice(iv)); } @@ -242,9 +229,7 @@ class AesCbcEncryptBench final : public td::Benchmark { } void start_up() final { - for (int i = 0; i < DATA_SIZE; i++) { - data[i] = 123; - } + std::fill(std::begin(data), std::end(data), static_cast(123)); td::Random::secure_bytes(as_slice(key)); td::Random::secure_bytes(as_slice(iv)); } @@ -269,9 +254,7 @@ class AesIgeShortBench final : public td::Benchmark { } void start_up() final { - for (int i = 0; i < SHORT_DATA_SIZE; i++) { - data[i] = 123; - } + std::fill(std::begin(data), std::end(data), static_cast(123)); td::Random::secure_bytes(as_slice(key)); td::Random::secure_bytes(as_slice(iv)); } @@ -372,10 +355,7 @@ class Crc32Bench final : public td::Benchmark { } void start_up() final { - for (int i = 0; i < DATA_SIZE; i++) { - data[i] = 123; - data[i] = 0; - } + std::fill(std::begin(data), std::end(data), static_cast(123)); } void run(int n) final { @@ -396,10 +376,7 @@ class Crc64Bench final : public td::Benchmark { } void start_up() final { - for (int i = 0; i < DATA_SIZE; i++) { - data[i] = 123; - data[i] = 0; - } + std::fill(std::begin(data), std::end(data), static_cast(123)); } void run(int n) final { diff --git a/benchmark/check_tls.cpp b/benchmark/check_tls.cpp index afc80b800..b2fa2ecd0 100644 --- a/benchmark/check_tls.cpp +++ b/benchmark/check_tls.cpp @@ -96,8 +96,8 @@ td::Result test_tls(const td::string &url) { const size_t MAX_GREASE = 7; char greases[MAX_GREASE]; td::Random::secure_bytes(td::MutableSlice{greases, MAX_GREASE}); - for (size_t i = 0; i < MAX_GREASE; i++) { - greases[i] = static_cast((greases[i] & 0xF0) + 0x0A); + for (auto &grease : greases) { + grease = static_cast((grease & 0xF0) + 0x0A); } for (size_t i = 1; i < MAX_GREASE; i += 2) { if (greases[i] == greases[i - 1]) { diff --git a/td/telegram/MessageEntity.cpp b/td/telegram/MessageEntity.cpp index 0a4203f0c..c091b7ec7 100644 --- a/td/telegram/MessageEntity.cpp +++ b/td/telegram/MessageEntity.cpp @@ -2223,8 +2223,8 @@ static FormattedText parse_text_url_entities_v3(Slice text, const vector(recent_sticker_ids_[is_attached].size()) > recent_stickers_limit) { recent_sticker_ids_[is_attached].resize(recent_stickers_limit); + need_update_recent_stickers_[is_attached] = true; send_update_recent_stickers(); } } diff --git a/tdtl/td/tl/tl_simple.h b/tdtl/td/tl/tl_simple.h index 67ad2a1aa..7647981bf 100644 --- a/tdtl/td/tl/tl_simple.h +++ b/tdtl/td/tl/tl_simple.h @@ -23,9 +23,9 @@ namespace tl { namespace simple { inline std::string gen_cpp_name(std::string name) { - for (std::size_t i = 0; i < name.size(); i++) { - if ((name[i] < '0' || '9' < name[i]) && (name[i] < 'a' || 'z' < name[i]) && (name[i] < 'A' || 'Z' < name[i])) { - name[i] = '_'; + for (auto &c : name) { + if ((c < '0' || '9' < c) && (c < 'a' || 'z' < c) && (c < 'A' || 'Z' < c)) { + c = '_'; } } assert(!name.empty());