Minor fixes.

GitOrigin-RevId: 39fb006dd5d935f6dd0b400114d71391463450eb
This commit is contained in:
levlam 2019-03-17 23:43:58 +03:00
parent f9a0b34cb2
commit b5407cd6bc
6 changed files with 11 additions and 8 deletions

View File

@ -21,7 +21,6 @@
#include "td/telegram/StateManager.h" #include "td/telegram/StateManager.h"
#include "td/telegram/TdDb.h" #include "td/telegram/TdDb.h"
#include "td/telegram/Td.h" #include "td/telegram/Td.h"
#include "td/telegram/TdParameters.h"
#include "td/telegram/UpdatesManager.h" #include "td/telegram/UpdatesManager.h"
#include "td/db/binlog/BinlogEvent.h" #include "td/db/binlog/BinlogEvent.h"
@ -335,7 +334,7 @@ vector<int32> PollManager::get_vote_percentage(const vector<int32> &voter_counts
// just round to the nearest // just round to the nearest
for (size_t i = 0; i < result.size(); i++) { for (size_t i = 0; i < result.size(); i++) {
result[i] = result[i] =
static_cast<int32>((static_cast<int64_t>(voter_counts[i]) * 200 + total_voter_count) / total_voter_count / 2); static_cast<int32>((static_cast<int64>(voter_counts[i]) * 200 + total_voter_count) / total_voter_count / 2);
} }
return result; return result;
} }
@ -344,10 +343,10 @@ vector<int32> PollManager::get_vote_percentage(const vector<int32> &voter_counts
int32 percent_sum = 0; int32 percent_sum = 0;
vector<int32> gap(voter_counts.size(), 0); vector<int32> gap(voter_counts.size(), 0);
for (size_t i = 0; i < result.size(); i++) { for (size_t i = 0; i < result.size(); i++) {
auto multiplied_voter_count = static_cast<int64_t>(voter_counts[i]) * 100; auto multiplied_voter_count = static_cast<int64>(voter_counts[i]) * 100;
result[i] = static_cast<int32>(multiplied_voter_count / total_voter_count); result[i] = static_cast<int32>(multiplied_voter_count / total_voter_count);
CHECK(0 <= result[i] && result[i] <= 100); CHECK(0 <= result[i] && result[i] <= 100);
gap[i] = static_cast<int32>(static_cast<int64_t>(result[i] + 1) * total_voter_count - multiplied_voter_count); gap[i] = static_cast<int32>(static_cast<int64>(result[i] + 1) * total_voter_count - multiplied_voter_count);
CHECK(0 <= gap[i] && gap[i] <= total_voter_count); CHECK(0 <= gap[i] && gap[i] <= total_voter_count);
percent_sum += result[i]; percent_sum += result[i];
} }

View File

@ -6,6 +6,7 @@
// //
#include "td/telegram/QueryCombiner.h" #include "td/telegram/QueryCombiner.h"
#include "td/utils/logging.h"
#include "td/utils/Time.h" #include "td/utils/Time.h"
namespace td { namespace td {

View File

@ -10,8 +10,9 @@
#include "td/actor/PromiseFuture.h" #include "td/actor/PromiseFuture.h"
#include "td/utils/common.h" #include "td/utils/common.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
#include <functional>
#include <queue> #include <queue>
#include <unordered_map> #include <unordered_map>

View File

@ -9,6 +9,7 @@
#include "td/utils/format.h" #include "td/utils/format.h"
#include "td/utils/logging.h" #include "td/utils/logging.h"
#include "td/utils/misc.h" #include "td/utils/misc.h"
#include "td/utils/ScopeGuard.h"
#include <limits> #include <limits>
#include <numeric> #include <numeric>
@ -225,9 +226,7 @@ bool PartsManager::is_part_in_streaming_limit(int part_i) const {
return true; return true;
} }
auto is_intersect_with = [&](int64 begin, int64 end) { auto is_intersect_with = [&](int64 begin, int64 end) { return max(begin, offset_begin) < min(end, offset_end); };
return std::max(begin, offset_begin) < std::min(end, offset_end);
};
auto streaming_begin = streaming_offset_; auto streaming_begin = streaming_offset_;
auto streaming_end = streaming_offset_ + streaming_limit_; auto streaming_end = streaming_offset_ + streaming_limit_;

View File

@ -13,6 +13,8 @@
#include "td/utils/logging.h" #include "td/utils/logging.h"
#include "td/utils/Slice.h" #include "td/utils/Slice.h"
#include <algorithm>
namespace td { namespace td {
SessionMultiProxy::SessionMultiProxy() = default; SessionMultiProxy::SessionMultiProxy() = default;

View File

@ -11,6 +11,7 @@
#include "td/telegram/net/DcId.h" #include "td/telegram/net/DcId.h"
#include "td/telegram/net/NetQueryDispatcher.h" #include "td/telegram/net/NetQueryDispatcher.h"
#include "td/telegram/net/Session.h" #include "td/telegram/net/Session.h"
#include "td/telegram/UniqueId.h"
#include "td/actor/PromiseFuture.h" #include "td/actor/PromiseFuture.h"