Clean up explicit conversions to ObjPtr<>.
Add an ObjPtr<>::DownCast() overload that takes a plain
pointer and remove unnecessary calls to MakeObjPtr(),
usually preceding DownCast(). Move the MakeObjPtr() to
common_art_test.h .
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 31113334
Change-Id: I2a243b6d8f3b2e773396dfc53b659c5f7d9ea44a
diff --git a/runtime/mirror/array-alloc-inl.h b/runtime/mirror/array-alloc-inl.h
index 4250ff8..2ae4cab 100644
--- a/runtime/mirror/array-alloc-inl.h
+++ b/runtime/mirror/array-alloc-inl.h
@@ -142,16 +142,16 @@
ObjPtr<Array> result;
if (!kFillUsable) {
SetLengthVisitor visitor(component_count);
- result = ObjPtr<Array>::DownCast(MakeObjPtr(
- heap->AllocObjectWithAllocator<kIsInstrumented, true>(self, array_class, size,
- allocator_type, visitor)));
+ result = ObjPtr<Array>::DownCast(
+ heap->AllocObjectWithAllocator<kIsInstrumented, true>(
+ self, array_class, size, allocator_type, visitor));
} else {
SetLengthToUsableSizeVisitor visitor(component_count,
DataOffset(1U << component_size_shift).SizeValue(),
component_size_shift);
- result = ObjPtr<Array>::DownCast(MakeObjPtr(
- heap->AllocObjectWithAllocator<kIsInstrumented, true>(self, array_class, size,
- allocator_type, visitor)));
+ result = ObjPtr<Array>::DownCast(
+ heap->AllocObjectWithAllocator<kIsInstrumented, true>(
+ self, array_class, size, allocator_type, visitor));
}
if (kIsDebugBuild && result != nullptr && Runtime::Current()->IsStarted()) {
array_class = result->GetClass(); // In case the array class moved.