diff options
author | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-04-15 15:18:34 +0200 |
---|---|---|
committer | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-05-04 16:08:55 +0200 |
commit | 955d5affa857ec1f358c56da8fb1ff4ab6590704 (patch) | |
tree | b667ac9f6f62bff17ce032683c0eb09727660555 /platform/android/java_godot_wrapper.cpp | |
parent | 7ebc866418b075df58cbe4e31fcf8b0c3acd70a1 (diff) | |
download | redot-engine-955d5affa857ec1f358c56da8fb1ff4ab6590704.tar.gz |
Reduce and prevent unnecessary random-access to `List`
Random-access access to `List` when iterating is `O(n^2)` (`O(n)` when
accessing a single element)
* Removed subscript operator, in favor of a more explicit `get`
* Added conversion from `Iterator` to `ConstIterator`
* Remade existing operations into other solutions when applicable
Diffstat (limited to 'platform/android/java_godot_wrapper.cpp')
-rw-r--r-- | platform/android/java_godot_wrapper.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/platform/android/java_godot_wrapper.cpp b/platform/android/java_godot_wrapper.cpp index 0e766e7d56..6e7f5ef5a1 100644 --- a/platform/android/java_godot_wrapper.cpp +++ b/platform/android/java_godot_wrapper.cpp @@ -351,8 +351,9 @@ int GodotJavaWrapper::create_new_godot_instance(const List<String> &args) { JNIEnv *env = get_jni_env(); ERR_FAIL_NULL_V(env, 0); jobjectArray jargs = env->NewObjectArray(args.size(), env->FindClass("java/lang/String"), env->NewStringUTF("")); - for (int i = 0; i < args.size(); i++) { - jstring j_arg = env->NewStringUTF(args[i].utf8().get_data()); + int i = 0; + for (List<String>::ConstIterator itr = args.begin(); itr != args.end(); ++itr, ++i) { + jstring j_arg = env->NewStringUTF(itr->utf8().get_data()); env->SetObjectArrayElement(jargs, i, j_arg); env->DeleteLocalRef(j_arg); } |