From 9ac24a05800c4960230c1f6f5f62412177717f9c Mon Sep 17 00:00:00 2001 From: Ryan Meredith Date: Wed, 22 Jul 2020 15:38:45 -0400 Subject: [PATCH] Android: Some simple Clang-Tidy suggestions --- Source/Android/jni/GameList/GameFile.cpp | 2 +- Source/Android/jni/GameList/GameFileCache.cpp | 2 +- Source/Android/jni/MainAndroid.cpp | 23 ++++++++++--------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Source/Android/jni/GameList/GameFile.cpp b/Source/Android/jni/GameList/GameFile.cpp index 71b8076275..741cf39b4f 100644 --- a/Source/Android/jni/GameList/GameFile.cpp +++ b/Source/Android/jni/GameList/GameFile.cpp @@ -188,7 +188,7 @@ JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getBan jobject obj) { const std::vector& buffer = GetRef(env, obj)->GetBannerImage().buffer; - const jsize size = static_cast(buffer.size()); + const auto size = static_cast(buffer.size()); const jintArray out_array = env->NewIntArray(size); if (!out_array) return nullptr; diff --git a/Source/Android/jni/GameList/GameFileCache.cpp b/Source/Android/jni/GameList/GameFileCache.cpp index 0d8aea8285..f6b81ae834 100644 --- a/Source/Android/jni/GameList/GameFileCache.cpp +++ b/Source/Android/jni/GameList/GameFileCache.cpp @@ -89,7 +89,7 @@ JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_model_GameFileCache_up for (jsize i = 0; i < size; ++i) { - const jstring path = reinterpret_cast(env->GetObjectArrayElement(folder_paths, i)); + const auto path = reinterpret_cast(env->GetObjectArrayElement(folder_paths, i)); folder_paths_vector.push_back(GetJString(env, path)); env->DeleteLocalRef(path); } diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp index 4b7a404086..f39f27a503 100644 --- a/Source/Android/jni/MainAndroid.cpp +++ b/Source/Android/jni/MainAndroid.cpp @@ -63,7 +63,7 @@ namespace { -static constexpr char DOLPHIN_TAG[] = "DolphinEmuNative"; +constexpr char DOLPHIN_TAG[] = "DolphinEmuNative"; ANativeWindow* s_surf; IniFile s_ini; @@ -157,7 +157,7 @@ static bool MsgAlert(const char* caption, const char* text, bool yes_no, Common: return result != JNI_FALSE; } -static void ReportSend(std::string endpoint, std::string report) +static void ReportSend(const std::string& endpoint, const std::string& report) { JNIEnv* env = IDCache::GetEnvForThread(); @@ -169,11 +169,11 @@ static void ReportSend(std::string endpoint, std::string report) ToJString(env, endpoint), output_array); } -static std::string GetAnalyticValue(std::string key) +static std::string GetAnalyticValue(const std::string& key) { JNIEnv* env = IDCache::GetEnvForThread(); - jstring value = reinterpret_cast(env->CallStaticObjectMethod( + auto value = reinterpret_cast(env->CallStaticObjectMethod( IDCache::GetAnalyticsClass(), IDCache::GetAnalyticsValue(), ToJString(env, key))); std::string stdvalue = GetJString(env, value); @@ -329,13 +329,13 @@ JNIEXPORT double JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetInputRa JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv* env, jobject obj) { - return ToJString(env, Common::scm_rev_str.c_str()); + return ToJString(env, Common::scm_rev_str); } JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGitRevision(JNIEnv* env, jobject obj) { - return ToJString(env, Common::scm_rev_git_str.c_str()); + return ToJString(env, Common::scm_rev_git_str); } JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveScreenShot(JNIEnv* env, @@ -372,12 +372,12 @@ JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetUserSe std::string section = GetJString(env, jSection); std::string key = GetJString(env, jKey); - ini = SConfig::GetInstance().LoadGameIni(gameid, 0); + ini = SConfig::LoadGameIni(gameid, 0); std::string value; ini.GetOrCreateSection(section)->Get(key, &value, "-1"); - return ToJString(env, value.c_str()); + return ToJString(env, value); } JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_NewGameIniFile(JNIEnv* env, @@ -457,7 +457,7 @@ JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig ini.GetOrCreateSection(section)->Get(key, &value, defaultValue); - return ToJString(env, value.c_str()); + return ToJString(env, value); } JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetConfig( @@ -533,7 +533,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetUserDirec JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetUserDirectory(JNIEnv* env, jobject obj) { - return ToJString(env, File::GetUserPath(D_USER_IDX).c_str()); + return ToJString(env, File::GetUserPath(D_USER_IDX)); } JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetCacheDirectory( @@ -683,7 +683,8 @@ static float GetRenderSurfaceScale(JNIEnv* env) } static void Run(JNIEnv* env, const std::vector& paths, - std::optional savestate_path = {}, bool delete_savestate = false) + const std::optional& savestate_path = {}, + bool delete_savestate = false) { ASSERT(!paths.empty()); __android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Running : %s", paths[0].c_str());