Minor fixes.

GitOrigin-RevId: ce9058c2075281697cc41de2ab970dd11e189f77
This commit is contained in:
levlam 2020-06-13 05:13:11 +03:00
parent c68481052a
commit 2ed9cb3b75
5 changed files with 15 additions and 17 deletions

View File

@ -257,7 +257,7 @@ class FileDb : public FileDbInterface {
while (true) {
if (attempt_count > 100) {
LOG(FATAL) << "Cycle in file database? current_pmc_id=" << current_pmc_id << " key=" << key
<< " links=" << td::format::as_array(ids);
<< " links=" << format::as_array(ids);
}
attempt_count++;

View File

@ -17,9 +17,9 @@
#include "td/utils/Random.h"
#include "td/utils/StorerBase.h"
#include "td/utils/Time.h"
#include "td/utils/tl_helpers.h"
#include "td/utils/tl_parsers.h"
#include "td/utils/tl_storers.h"
#include "td/utils/tl_helpers.h"
#include "td/utils/VectorQueue.h"
#include <algorithm>
@ -97,7 +97,6 @@ class TQueueImpl : public TQueue {
}
bool do_push(QueueId queue_id, RawEvent &&raw_event) override {
// LOG(ERROR) << "Push to queue " << queue_id << " " << raw_event.event_id;
CHECK(raw_event.event_id.is_valid());
auto &q = queues_[queue_id];
if (q.events.empty() || q.events.back().event_id < raw_event.event_id) {
@ -192,7 +191,6 @@ class TQueueImpl : public TQueue {
Result<size_t> get(QueueId queue_id, EventId from_id, bool forget_previous, double now,
MutableSpan<Event> &result_events) override {
// LOG(ERROR) << "Get " << queue_id << " " << from_id;
auto it = queues_.find(queue_id);
if (it == queues_.end()) {
result_events.truncate(0);
@ -220,7 +218,6 @@ class TQueueImpl : public TQueue {
[](auto &event, EventId event_id) { return event.event_id < event_id; }) -
from_events.begin();
}
// LOG(ERROR) << tag("first_i", first_i) << tag("size", from_events.size());
for (i = first_i; i < from_events.size(); i++) {
auto &from = from_events[i];
try_pop(queue_id, from, forget_previous ? from_id : EventId{}, q.tail_id, now);
@ -285,8 +282,6 @@ class TQueueImpl : public TQueue {
}
void try_pop(QueueId queue_id, RawEvent &event, EventId from_id, EventId tail_id, double now) {
// LOG(ERROR) << event.expires_at << " < " << now << " = " << (event.expires_at < now) << " "
// << (event.event_id < from_id) << " " << event.data.empty();
if (event.expires_at < now || event.event_id < from_id || event.data.empty()) {
pop(queue_id, event, tail_id);
}
@ -299,7 +294,6 @@ class TQueueImpl : public TQueue {
return;
}
// LOG(ERROR) << "Drop " << queue_id << " " << event.event_id;
if (event.event_id.next().ok() == tail_id) {
if (!event.data.empty()) {
event.data = {};

View File

@ -167,7 +167,7 @@ int Random::Xorshift128plus::fast(int min, int max) {
void Random::Xorshift128plus::bytes(MutableSlice dest) {
int cnt = 0;
td::uint64 buf = 0;
uint64 buf = 0;
for (auto &c : dest) {
if (cnt == 0) {
buf = operator()();

View File

@ -197,7 +197,7 @@ class HashMapBenchmark : public td::Benchmark {
return HashMap::get_name();
}
void start_up_n(int n) override {
n *= (int)threads_n;
n *= static_cast<int>(threads_n);
n_ = n;
hash_map = td::make_unique<HashMap>(n * 2);
}

View File

@ -66,17 +66,21 @@ static void do_run_list_test(ListRootT &root, std::atomic<td::uint64> &id) {
nodes.emplace_back(NodeT({next_id(), false}));
};
auto pop_node = [&] {
if (nodes.size() == 0) {
if (nodes.empty()) {
return;
}
nodes.pop_back();
};
auto random_node_index = [&] {
CHECK(!nodes.empty());
return rnd.fast(0, static_cast<int>(nodes.size()) - 1);
};
auto link_node = [&] {
if (nodes.empty()) {
return;
}
auto i = rnd.fast(0, (int)nodes.size() - 1);
auto i = random_node_index();
nodes[i].remove();
get_data(nodes[i]) = ListData(next_id(), true);
root.put(&nodes[i]);
@ -85,7 +89,7 @@ static void do_run_list_test(ListRootT &root, std::atomic<td::uint64> &id) {
if (nodes.empty()) {
return;
}
auto i = rnd.fast(0, (int)nodes.size() - 1);
auto i = random_node_index();
nodes[i].remove();
get_data(nodes[i]).in_list = false;
};
@ -93,16 +97,16 @@ static void do_run_list_test(ListRootT &root, std::atomic<td::uint64> &id) {
if (nodes.empty()) {
return;
}
auto i = rnd.fast(0, (int)nodes.size() - 1);
auto j = rnd.fast(0, (int)nodes.size() - 1);
auto i = random_node_index();
auto j = random_node_index();
std::swap(nodes[i], nodes[j]);
};
auto set_node = [&] {
if (nodes.empty()) {
return;
}
auto i = rnd.fast(0, (int)nodes.size() - 1);
auto j = rnd.fast(0, (int)nodes.size() - 1);
auto i = random_node_index();
auto j = random_node_index();
nodes[i] = std::move(nodes[j]);
};
auto validate = [&] {