From bba530f62890e4421f82713235cbef433e59d1ba Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Wed, 3 Jun 2015 22:40:23 -0700 Subject: [PATCH] Pre-sizing export tables. --- src/xenia/kernel/xam_module.cc | 10 +++------- src/xenia/kernel/xboxkrnl_module.cc | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/xenia/kernel/xam_module.cc b/src/xenia/kernel/xam_module.cc index 5a1da05c2..df3455eeb 100644 --- a/src/xenia/kernel/xam_module.cc +++ b/src/xenia/kernel/xam_module.cc @@ -35,12 +35,10 @@ XamModule::XamModule(Emulator* emulator, KernelState* kernel_state) xam::RegisterVoiceExports(export_resolver_, kernel_state_); } -std::vector xam_exports; +std::vector xam_exports(4096); xe::cpu::Export* RegisterExport_xam(xe::cpu::Export* export) { - if (xam_exports.size() <= export->ordinal) { - xam_exports.resize(xe::round_up(export->ordinal, 256)); - } + assert_true(export->ordinal < xam_exports.size()); xam_exports[export->ordinal] = export; return export; } @@ -56,9 +54,7 @@ void XamModule::RegisterExportTable(xe::cpu::ExportResolver* export_resolver) { #include "xenia/kernel/util/export_table_post.inc" for (size_t i = 0; i < xe::countof(xam_export_table); ++i) { auto& export = xam_export_table[i]; - if (xam_exports.size() <= export.ordinal) { - xam_exports.resize(xe::round_up(export.ordinal, 256)); - } + assert_true(export.ordinal < xam_exports.size()); if (!xam_exports[export.ordinal]) { xam_exports[export.ordinal] = &export; } diff --git a/src/xenia/kernel/xboxkrnl_module.cc b/src/xenia/kernel/xboxkrnl_module.cc index 8385d9a56..c0854c4ca 100644 --- a/src/xenia/kernel/xboxkrnl_module.cc +++ b/src/xenia/kernel/xboxkrnl_module.cc @@ -150,12 +150,10 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state) WT_EXECUTEINTIMERTHREAD); } -std::vector xboxkrnl_exports; +std::vector xboxkrnl_exports(4096); xe::cpu::Export* RegisterExport_xboxkrnl(xe::cpu::Export* export) { - if (xboxkrnl_exports.size() <= export->ordinal) { - xboxkrnl_exports.resize(xe::round_up(export->ordinal, 256)); - } + assert_true(export->ordinal < xboxkrnl_exports.size()); xboxkrnl_exports[export->ordinal] = export; return export; } @@ -172,9 +170,7 @@ void XboxkrnlModule::RegisterExportTable( #include "xenia/kernel/util/export_table_post.inc" for (size_t i = 0; i < xe::countof(xboxkrnl_export_table); ++i) { auto& export = xboxkrnl_export_table[i]; - if (xboxkrnl_exports.size() <= export.ordinal) { - xboxkrnl_exports.resize(xe::round_up(export.ordinal, 256)); - } + assert_true(export.ordinal < xboxkrnl_exports.size()); if (!xboxkrnl_exports[export.ordinal]) { xboxkrnl_exports[export.ordinal] = &export; }