Remove unnecessary static_cast.

GitOrigin-RevId: df5259458cd0d8d4a1b72da6950ea39553979c68
This commit is contained in:
levlam 2018-09-21 11:26:35 +03:00
parent 1362f0bd0a
commit 5322a65c1b
3 changed files with 3 additions and 5 deletions

View File

@ -37,7 +37,7 @@ Result<Client::Request> ClientJson::to_request(Slice request) {
} }
std::string ClientJson::from_response(Client::Response response) { std::string ClientJson::from_response(Client::Response response) {
auto str = json_encode<string>(ToJson(static_cast<td_api::Object &>(*response.object))); auto str = json_encode<string>(ToJson(*response.object));
CHECK(!str.empty() && str.back() == '}'); CHECK(!str.empty() && str.back() == '}');
std::string extra; std::string extra;
if (response.id != 0) { if (response.id != 0) {

View File

@ -32,9 +32,7 @@ TdResponse TdCClientReceive(void *instance, double timeout) {
auto response = client->receive(timeout); auto response = client->receive(timeout);
TdResponse c_response; TdResponse c_response;
c_response.id = response.id; c_response.id = response.id;
c_response.object = response.object == nullptr c_response.object = response.object == nullptr ? nullptr : TdConvertFromInternal(*response.object);
? nullptr
: TdConvertFromInternal(static_cast<const td::td_api::Object &>(*response.object));
return c_response; return c_response;
} }

View File

@ -743,7 +743,7 @@ StrT json_encode(const ValT &val) {
auto buf = StackAllocator::alloc(buf_len); auto buf = StackAllocator::alloc(buf_len);
JsonBuilder jb(StringBuilder(buf.as_slice())); JsonBuilder jb(StringBuilder(buf.as_slice()));
jb.enter_value() << val; jb.enter_value() << val;
LOG_IF(ERROR, jb.string_builder().is_error()) << "Json buffer overflow"; LOG_IF(ERROR, jb.string_builder().is_error()) << "JSON buffer overflow";
auto slice = jb.string_builder().as_cslice(); auto slice = jb.string_builder().as_cslice();
return StrT(slice.begin(), slice.size()); return StrT(slice.begin(), slice.size());
} }