summaryrefslogtreecommitdiff
path: root/runtime/class_loader_utils.h
diff options
context:
space:
mode:
author Alex Light <allight@google.com> 2019-11-14 14:51:41 -0800
committer Treehugger Robot <treehugger-gerrit@google.com> 2019-11-15 19:17:23 +0000
commita9bbc08daad6d601c870c8493323f57b70373336 (patch)
tree8ca74373cac0fe52aced5f32cc6f6e1f9c3239b5 /runtime/class_loader_utils.h
parent56f1332113c3b8b1844c04683b9cb9dc5a0bd346 (diff)
Implement STL iterators on ObjectArray and add helpers
Iterating over an ObjectArray is rather cumbersome, requiring manual for-loops. To improve ergonomics and STL standard-ness this implements std::iterator's for ObjectArray and converts code to use this (in simple situations). This should allow us to use standard STL functions in the future when dealing with ObjectArrays. Also adds some helpers such as ZipCount and ZipLeft. Test: ./test.py --host Change-Id: Ifd515b8321775424b3256a6faf47b2ba970177d3
Diffstat (limited to 'runtime/class_loader_utils.h')
-rw-r--r--runtime/class_loader_utils.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/runtime/class_loader_utils.h b/runtime/class_loader_utils.h
index 2e8504391a..1c353604fa 100644
--- a/runtime/class_loader_utils.h
+++ b/runtime/class_loader_utils.h
@@ -23,6 +23,7 @@
#include "jni/jni_internal.h"
#include "mirror/class_loader.h"
#include "mirror/object-inl.h"
+#include "mirror/object.h"
#include "native/dalvik_system_DexFile.h"
#include "scoped_thread_state_change-inl.h"
#include "well_known_classes.h"
@@ -86,8 +87,7 @@ inline RetType VisitClassLoaderDexElements(ScopedObjectAccessAlreadyRunnable& so
StackHandleScope<1> hs(self);
Handle<mirror::ObjectArray<mirror::Object>> dex_elements =
hs.NewHandle(dex_elements_obj->AsObjectArray<mirror::Object>());
- for (int32_t i = 0; i < dex_elements->GetLength(); ++i) {
- ObjPtr<mirror::Object> element = dex_elements->GetWithoutChecks(i);
+ for (auto element : dex_elements.Iterate<mirror::Object>()) {
if (element == nullptr) {
// Should never happen, fail.
break;