Remove unneeded reinterpret casts.

GitOrigin-RevId: 54a161ad11e5909f9c06912cf67e6805279f2327
This commit is contained in:
levlam 2018-12-20 00:44:15 +03:00
parent b676fe509a
commit 22eb4e1cb2
5 changed files with 13 additions and 13 deletions

View File

@ -182,7 +182,7 @@ static vector<Slice> match_mentions(Slice str) {
// '/(?<=\B)@([a-zA-Z0-9_]{2,32})(?=\b)/u' // '/(?<=\B)@([a-zA-Z0-9_]{2,32})(?=\b)/u'
while (true) { while (true) {
ptr = reinterpret_cast<const unsigned char *>(std::memchr(ptr, '@', narrow_cast<int32>(end - ptr))); ptr = static_cast<const unsigned char *>(std::memchr(ptr, '@', narrow_cast<int32>(end - ptr)));
if (ptr == nullptr) { if (ptr == nullptr) {
break; break;
} }
@ -226,7 +226,7 @@ static vector<Slice> match_bot_commands(Slice str) {
// '/(?<!\b|[\/<>])\/([a-zA-Z0-9_]{1,64})(?:@([a-zA-Z0-9_]{3,32}))?(?!\B|[\/<>])/u' // '/(?<!\b|[\/<>])\/([a-zA-Z0-9_]{1,64})(?:@([a-zA-Z0-9_]{3,32}))?(?!\B|[\/<>])/u'
while (true) { while (true) {
ptr = reinterpret_cast<const unsigned char *>(std::memchr(ptr, '/', narrow_cast<int32>(end - ptr))); ptr = static_cast<const unsigned char *>(std::memchr(ptr, '/', narrow_cast<int32>(end - ptr)));
if (ptr == nullptr) { if (ptr == nullptr) {
break; break;
} }
@ -302,7 +302,7 @@ static vector<Slice> match_hashtags(Slice str) {
UnicodeSimpleCategory category; UnicodeSimpleCategory category;
while (true) { while (true) {
ptr = reinterpret_cast<const unsigned char *>(std::memchr(ptr, '#', narrow_cast<int32>(end - ptr))); ptr = static_cast<const unsigned char *>(std::memchr(ptr, '#', narrow_cast<int32>(end - ptr)));
if (ptr == nullptr) { if (ptr == nullptr) {
break; break;
} }
@ -363,7 +363,7 @@ static vector<Slice> match_cashtags(Slice str) {
UnicodeSimpleCategory category; UnicodeSimpleCategory category;
while (true) { while (true) {
ptr = reinterpret_cast<const unsigned char *>(std::memchr(ptr, '$', narrow_cast<int32>(end - ptr))); ptr = static_cast<const unsigned char *>(std::memchr(ptr, '$', narrow_cast<int32>(end - ptr)));
if (ptr == nullptr) { if (ptr == nullptr) {
break; break;
} }

View File

@ -68,7 +68,7 @@ class tl_simple_parser {
std::int64_t fetch_long() { std::int64_t fetch_long() {
check_len(sizeof(std::int64_t)); check_len(sizeof(std::int64_t));
std::int64_t result; std::int64_t result;
std::memcpy(reinterpret_cast<char *>(&result), data, sizeof(std::int64_t)); std::memcpy(&result, data, sizeof(std::int64_t));
data += sizeof(std::int64_t); data += sizeof(std::int64_t);
return result; return result;
} }

View File

@ -50,7 +50,7 @@ class Parser {
if (status_.is_error()) { if (status_.is_error()) {
return MutableSlice(); return MutableSlice();
} }
char *till = reinterpret_cast<char *>(std::memchr(ptr_, c, end_ - ptr_)); char *till = static_cast<char *>(std::memchr(ptr_, c, end_ - ptr_));
if (till == nullptr) { if (till == nullptr) {
till = end_; till = end_;
} }
@ -65,7 +65,7 @@ class Parser {
} }
char *best_till = end_; char *best_till = end_;
for (auto c : str) { for (auto c : str) {
char *till = reinterpret_cast<char *>(std::memchr(ptr_, c, end_ - ptr_)); char *till = static_cast<char *>(std::memchr(ptr_, c, end_ - ptr_));
if (till != nullptr && till < best_till) { if (till != nullptr && till < best_till) {
best_till = till; best_till = till;
} }

View File

@ -51,7 +51,7 @@ class TlParser {
data_buf = std::make_unique<int32[]>(1 + data_len / sizeof(int32)); data_buf = std::make_unique<int32[]>(1 + data_len / sizeof(int32));
buf = data_buf.get(); buf = data_buf.get();
} }
std::memcpy(static_cast<void *>(buf), static_cast<const void *>(slice.begin()), slice.size()); std::memcpy(buf, slice.begin(), slice.size());
data = reinterpret_cast<unsigned char *>(buf); data = reinterpret_cast<unsigned char *>(buf);
} }
} }
@ -89,7 +89,7 @@ class TlParser {
int32 fetch_int_unsafe() { int32 fetch_int_unsafe() {
int32 result; int32 result;
std::memcpy(reinterpret_cast<unsigned char *>(&result), data, sizeof(int32)); std::memcpy(&result, data, sizeof(int32));
data += sizeof(int32); data += sizeof(int32);
return result; return result;
} }
@ -101,7 +101,7 @@ class TlParser {
int64 fetch_long_unsafe() { int64 fetch_long_unsafe() {
int64 result; int64 result;
std::memcpy(reinterpret_cast<unsigned char *>(&result), data, sizeof(int64)); std::memcpy(&result, data, sizeof(int64));
data += sizeof(int64); data += sizeof(int64);
return result; return result;
} }
@ -113,7 +113,7 @@ class TlParser {
double fetch_double_unsafe() { double fetch_double_unsafe() {
double result; double result;
std::memcpy(reinterpret_cast<unsigned char *>(&result), data, sizeof(double)); std::memcpy(&result, data, sizeof(double));
data += sizeof(double); data += sizeof(double);
return result; return result;
} }
@ -126,7 +126,7 @@ class TlParser {
template <class T> template <class T>
T fetch_binary_unsafe() { T fetch_binary_unsafe() {
T result; T result;
std::memcpy(reinterpret_cast<unsigned char *>(&result), data, sizeof(T)); std::memcpy(&result, data, sizeof(T));
data += sizeof(T); data += sizeof(T);
return result; return result;
} }

View File

@ -31,7 +31,7 @@ class TlStorerUnsafe {
template <class T> template <class T>
void store_binary(const T &x) { void store_binary(const T &x) {
std::memcpy(buf_, reinterpret_cast<const unsigned char *>(&x), sizeof(T)); std::memcpy(buf_, &x, sizeof(T));
buf_ += sizeof(T); buf_ += sizeof(T);
} }