ART: Extracts an utility function of the duplicated code
This patch introduces an utility function 'DataOffsetOfType' in
'mirror::Array' class that calculates the data offset at given index
in an array of given type.
Change-Id: Idb19558653c70a129245f220f0fbb553f898865b
Signed-off-by: Dmitry Petrochenko <dmitry.petrochenko@intel.com>
diff --git a/runtime/mirror/array.h b/runtime/mirror/array.h
index 772d303..a9dcfe6 100644
--- a/runtime/mirror/array.h
+++ b/runtime/mirror/array.h
@@ -68,6 +68,12 @@
}
}
+ template<class MirrorType>
+ static int32_t DataOffsetOfType(uint32_t index) {
+ return DataOffset(sizeof(HeapReference<MirrorType>)).Int32Value() +
+ (sizeof(HeapReference<MirrorType>) * index);
+ }
+
void* GetRawData(size_t component_size, int32_t index)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
intptr_t data = reinterpret_cast<intptr_t>(this) + DataOffset(component_size).Int32Value() +