diff options
| author | JosJuice <josjuice@gmail.com> | 2024-06-15 20:02:10 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2024-06-15 20:06:34 +0200 |
| commit | ea7928b3cda5749ba1dcc8e534b1474a28efb28a (patch) | |
| tree | aedb0d9cbcc07d03e008a42c3e5b984ffb7c6088 /Source/Android/jni/MainAndroid.cpp | |
| parent | 04c246d11f60719d20af67c230cfe0a866dcaf54 (diff) | |
Android: Replace log type names map with array
Storing the log type names in a map results in them getting re-sorted by
their keys, which doesn't quite give us the sorting we want. In
particular, the Achievements category ended up being sorted at R (for
RetroAchivements) instead of at A. Every use of the map is just
iterating through it, so there's no real reason why it has to be a map
anyway.
Diffstat (limited to 'Source/Android/jni/MainAndroid.cpp')
| -rw-r--r-- | Source/Android/jni/MainAndroid.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp index 9fcf1b33a3..d1f23383fa 100644 --- a/Source/Android/jni/MainAndroid.cpp +++ b/Source/Android/jni/MainAndroid.cpp @@ -14,6 +14,7 @@ #include <string> #include <thread> #include <utility> +#include <vector> #include "Common/AndroidAnalytics.h" #include "Common/Assert.h" @@ -648,27 +649,25 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ChangeDisc(J system.GetDVDInterface().ChangeDisc(Core::CPUThreadGuard{system}, path); } -JNIEXPORT jobject JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetLogTypeNames(JNIEnv* env, - jclass) +JNIEXPORT jobjectArray JNICALL +Java_org_dolphinemu_dolphinemu_NativeLibrary_GetLogTypeNames(JNIEnv* env, jclass) { - std::map<std::string, std::string> map = Common::Log::LogManager::GetInstance()->GetLogTypes(); + using LogManager = Common::Log::LogManager; - auto map_size = static_cast<jsize>(map.size()); - jobject linked_hash_map = - env->NewObject(IDCache::GetLinkedHashMapClass(), IDCache::GetLinkedHashMapInit(), map_size); - for (const auto& entry : map) - { - jstring key = ToJString(env, entry.first); - jstring value = ToJString(env, entry.second); + return VectorToJObjectArray( + env, LogManager::GetInstance()->GetLogTypes(), IDCache::GetPairClass(), + [](JNIEnv* env_, const LogManager::LogContainer& log_container) { + jstring short_name = ToJString(env_, log_container.m_short_name); + jstring full_name = ToJString(env_, log_container.m_full_name); - jobject result = - env->CallObjectMethod(linked_hash_map, IDCache::GetLinkedHashMapPut(), key, value); + jobject pair = env_->NewObject(IDCache::GetPairClass(), IDCache::GetPairConstructor(), + short_name, full_name); - env->DeleteLocalRef(key); - env->DeleteLocalRef(value); - env->DeleteLocalRef(result); - } - return linked_hash_map; + env_->DeleteLocalRef(short_name); + env_->DeleteLocalRef(full_name); + + return pair; + }); } JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ReloadLoggerConfig(JNIEnv*, |
