aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2018-12-20 00:44:15 +0300
committerlevlam <levlam@telegram.org>2018-12-20 00:44:15 +0300
commit22eb4e1cb2b92bbf142318506e0c90bf907b22d8 (patch)
treedd2c30af6af248c2762ff1547038b244a8c4b77e
parentb676fe509ade8ad9a0f5d2a0727d61440ecf2382 (diff)
Remove unneeded reinterpret casts.
GitOrigin-RevId: 54a161ad11e5909f9c06912cf67e6805279f2327
-rw-r--r--td/telegram/MessageEntity.cpp8
-rw-r--r--tdtl/td/tl/tl_simple_parser.h2
-rw-r--r--tdutils/td/utils/Parser.h4
-rw-r--r--tdutils/td/utils/tl_parsers.h10
-rw-r--r--tdutils/td/utils/tl_storers.h2
5 files changed, 13 insertions, 13 deletions
diff --git a/td/telegram/MessageEntity.cpp b/td/telegram/MessageEntity.cpp
index 05deaceca..a087ea842 100644
--- a/td/telegram/MessageEntity.cpp
+++ b/td/telegram/MessageEntity.cpp
@@ -182,7 +182,7 @@ static vector<Slice> match_mentions(Slice str) {
// '/(?<=\B)@([a-zA-Z0-9_]{2,32})(?=\b)/u'
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) {
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'
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) {
break;
}
@@ -302,7 +302,7 @@ static vector<Slice> match_hashtags(Slice str) {
UnicodeSimpleCategory category;
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) {
break;
}
@@ -363,7 +363,7 @@ static vector<Slice> match_cashtags(Slice str) {
UnicodeSimpleCategory category;
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) {
break;
}
diff --git a/tdtl/td/tl/tl_simple_parser.h b/tdtl/td/tl/tl_simple_parser.h
index 9e612bf79..644fee09b 100644
--- a/tdtl/td/tl/tl_simple_parser.h
+++ b/tdtl/td/tl/tl_simple_parser.h
@@ -68,7 +68,7 @@ class tl_simple_parser {
std::int64_t fetch_long() {
check_len(sizeof(std::int64_t));
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);
return result;
}
diff --git a/tdutils/td/utils/Parser.h b/tdutils/td/utils/Parser.h
index e1e55b592..a78b05db4 100644
--- a/tdutils/td/utils/Parser.h
+++ b/tdutils/td/utils/Parser.h
@@ -50,7 +50,7 @@ class Parser {
if (status_.is_error()) {
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) {
till = end_;
}
@@ -65,7 +65,7 @@ class Parser {
}
char *best_till = end_;
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) {
best_till = till;
}
diff --git a/tdutils/td/utils/tl_parsers.h b/tdutils/td/utils/tl_parsers.h
index 3df28255a..4eb52f70b 100644
--- a/tdutils/td/utils/tl_parsers.h
+++ b/tdutils/td/utils/tl_parsers.h
@@ -51,7 +51,7 @@ class TlParser {
data_buf = std::make_unique<int32[]>(1 + data_len / sizeof(int32));
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);
}
}
@@ -89,7 +89,7 @@ class TlParser {
int32 fetch_int_unsafe() {
int32 result;
- std::memcpy(reinterpret_cast<unsigned char *>(&result), data, sizeof(int32));
+ std::memcpy(&result, data, sizeof(int32));
data += sizeof(int32);
return result;
}
@@ -101,7 +101,7 @@ class TlParser {
int64 fetch_long_unsafe() {
int64 result;
- std::memcpy(reinterpret_cast<unsigned char *>(&result), data, sizeof(int64));
+ std::memcpy(&result, data, sizeof(int64));
data += sizeof(int64);
return result;
}
@@ -113,7 +113,7 @@ class TlParser {
double fetch_double_unsafe() {
double result;
- std::memcpy(reinterpret_cast<unsigned char *>(&result), data, sizeof(double));
+ std::memcpy(&result, data, sizeof(double));
data += sizeof(double);
return result;
}
@@ -126,7 +126,7 @@ class TlParser {
template <class T>
T fetch_binary_unsafe() {
T result;
- std::memcpy(reinterpret_cast<unsigned char *>(&result), data, sizeof(T));
+ std::memcpy(&result, data, sizeof(T));
data += sizeof(T);
return result;
}
diff --git a/tdutils/td/utils/tl_storers.h b/tdutils/td/utils/tl_storers.h
index c00fcd1e8..4f6cee125 100644
--- a/tdutils/td/utils/tl_storers.h
+++ b/tdutils/td/utils/tl_storers.h
@@ -31,7 +31,7 @@ class TlStorerUnsafe {
template <class T>
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);
}