[core] Embrace c++20 (#352)

This commit is contained in:
LoveSy 2021-03-13 15:11:53 +08:00 committed by GitHub
parent 7086c682c2
commit 52d0e98e83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View File

@ -49,6 +49,7 @@ namespace lspd {
operator std::string_view() const { operator std::string_view() const {
return c_str(); return c_str();
} }
private: private:
constexpr static char str_[]{chars..., '\0'}; constexpr static char str_[]{chars..., '\0'};
}; };
@ -67,12 +68,14 @@ namespace lspd {
template<char... as> template<char... as>
inline constexpr auto operator+(const std::string &a, const tstring<as...> &) { inline constexpr auto operator+(const std::string &a, const tstring<as...> &) {
return a + std::string{as..., '\0'}; char b[]{as..., '\0'};
return a + b;
} }
template<char... as> template<char... as>
inline constexpr auto operator+(const tstring<as...> &, const std::string &b) { inline constexpr auto operator+(const tstring<as...> &, const std::string &b) {
return std::string{as..., '\0'} + b; char a[]{as..., '\0'};
return a + b;
} }
} }

View File

@ -32,7 +32,7 @@ namespace lspd {
LSP_DEF_NATIVE_METHOD(void, ClassLinker, setEntryPointsToInterpreter, jobject method) { LSP_DEF_NATIVE_METHOD(void, ClassLinker, setEntryPointsToInterpreter, jobject method) {
void *reflected_method = getArtMethodYahfa(env, method); void *reflected_method = getArtMethodYahfa(env, method);
if (deopted_methods.count(reflected_method)) { if (deopted_methods.contains(reflected_method)) {
LOGD("method %p has been deopted before, skip...", reflected_method); LOGD("method %p has been deopted before, skip...", reflected_method);
return; return;
} }

View File

@ -42,14 +42,14 @@ namespace lspd {
bool IsClassPending(void *clazz) { bool IsClassPending(void *clazz) {
std::shared_lock lk(pending_classes_lock_); std::shared_lock lk(pending_classes_lock_);
return pending_classes_.count(clazz); return pending_classes_.contains(clazz);
} }
bool IsMethodPending(void *art_method) { bool IsMethodPending(void *art_method) {
bool result; bool result;
{ {
std::shared_lock lk(pending_methods_lock_); std::shared_lock lk(pending_methods_lock_);
result = pending_methods_.count(art_method); result = pending_methods_.contains(art_method);
} }
if (result) { if (result) {
std::unique_lock lk(pending_methods_lock_); std::unique_lock lk(pending_methods_lock_);
@ -96,7 +96,7 @@ namespace lspd {
bool isHooked(void *art_method) { bool isHooked(void *art_method) {
std::shared_lock lk(hooked_methods_lock_); std::shared_lock lk(hooked_methods_lock_);
return hooked_methods_.count(art_method); return hooked_methods_.contains(art_method);
} }
void recordHooked(void *art_method) { void recordHooked(void *art_method) {