kern: avoid constexpr init for many objects (avoids unnecessary memory clear) (#1668)

This commit is contained in:
SciresM 2021-10-23 15:25:20 -07:00 committed by GitHub
parent 20716cb3de
commit 36e4914be8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
77 changed files with 489 additions and 339 deletions

View file

@ -195,9 +195,11 @@ namespace ams::kern::KDumpObject {
char name[9] = {};
{
/* Find the client port process. */
KScopedAutoObject<KProcess> client_port_process;
KProcess *client_port_process = nullptr;
ON_SCOPE_EXIT { if (client_port_process != nullptr) { client_port_process->Close(); } };
{
for (auto it = accessor.begin(); it != end && client_port_process.IsNull(); ++it) {
for (auto it = accessor.begin(); it != end && client_port_process == nullptr; ++it) {
KProcess *cur = static_cast<KProcess *>(std::addressof(*it));
for (size_t j = 0; j < cur->GetHandleTable().GetTableSize(); ++j) {
ams::svc::Handle cur_h = ams::svc::InvalidHandle;
@ -205,6 +207,7 @@ namespace ams::kern::KDumpObject {
if (cur_o.IsNotNull()) {
if (cur_o.GetPointerUnsafe() == client) {
client_port_process = cur;
client_port_process->Open();
break;
}
}
@ -213,7 +216,7 @@ namespace ams::kern::KDumpObject {
}
/* Read the port name. */
if (client_port_process.IsNotNull()) {
if (client_port_process != nullptr) {
if (R_FAILED(client_port_process->GetPageTable().CopyMemoryFromLinearToKernel(KProcessAddress(name), 8, port_name, KMemoryState_None, KMemoryState_None, KMemoryPermission_UserRead, KMemoryAttribute_None, KMemoryAttribute_None))) {
std::memset(name, 0, sizeof(name));
}