template <typename Container>
ObjPtr<mirror::ObjectArray<mirror::String>> CreateStringArray(
Thread* self, size_t size, const Container& entries) REQUIRES_SHARED(Locks::mutator_lock_) {
StackHandleScope<1u> hs(self);
Handle<mirror::ObjectArray<mirror::String>> array = hs.NewHandle(
mirror::ObjectArray<mirror::String>::Alloc(
self, GetClassRoot<mirror::ObjectArray<mirror::String>>(), size)); if (array == nullptr) {
DCHECK(self->IsExceptionPending()); return nullptr;
} // Note: If the container's iterator returns a `std::string` by value, the `auto&&` // binds as a const reference and extends the lifetime of the temporary object.
size_t pos = 0u; for (auto&& entry : entries) {
ObjPtr<mirror::String> oentry =
mirror::String::AllocFromModifiedUtf8(self, detail::GetStringCStr(entry)); if (oentry == nullptr) {
DCHECK(self->IsExceptionPending()); return nullptr;
} // We're initializing a newly allocated array object, so we do not need to record that under // a transaction. If the transaction is aborted, the whole object shall be unreachable.
DCHECK_LT(pos, size);
array->SetWithoutChecks</*kTransactionActive=*/ false, /*kCheckTransaction=*/ false>(
pos, oentry);
++pos;
}
DCHECK_EQ(pos, size); return array.Get();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.