Skip to content

Commit

Permalink
Minor fixes.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: ce9058c2075281697cc41de2ab970dd11e189f77
  • Loading branch information
levlam committed Jun 13, 2020
1 parent c684810 commit 2ed9cb3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion td/telegram/files/FileDb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;

Expand Down
8 changes: 1 addition & 7 deletions tddb/td/db/TQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand All @@ -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 = {};
Expand Down
2 changes: 1 addition & 1 deletion tdutils/td/utils/Random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()();
Expand Down
2 changes: 1 addition & 1 deletion tdutils/test/ConcurrentHashMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
18 changes: 11 additions & 7 deletions tdutils/test/List.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -85,24 +89,24 @@ 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;
};
auto swap_nodes = [&] {
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 = [&] {
Expand Down

0 comments on commit 2ed9cb3

Please sign in to comment.