Stratosphère: Simplify some for loops (#76)

Simplifies some loops by removing the need to manually calculate or
re-specify the array size. Eliminates any chance of using the
wrong size and less typing.
This commit is contained in:
Léo Lam 2018-05-04 01:24:34 +02:00 committed by SciresM
parent 7ab9f507cb
commit 999498c0a0
3 changed files with 12 additions and 12 deletions

View file

@ -151,11 +151,11 @@ int main(int argc, char **argv)
LaunchTitle(0x0100000000000007, 3, 0, NULL);
bool maintenance = ShouldForceMaintenanceMode();
for (unsigned int i = 0; i < sizeof(g_additional_launch_programs) / sizeof(g_additional_launch_programs[0]); i++) {
if (!maintenance || std::get<bool>(g_additional_launch_programs[i])) {
LaunchTitle(std::get<u64>(g_additional_launch_programs[i]), 3, 0, NULL);
for (auto &launch_program : g_additional_launch_programs) {
if (!maintenance || std::get<bool>(launch_program)) {
LaunchTitle(std::get<u64>(launch_program), 3, 0, NULL);
}
}
return 0;
}
}

View file

@ -79,4 +79,4 @@ LaunchQueue::LaunchItem *LaunchQueue::get_item(u64 tid) {
return NULL;
}
return &g_launch_queue[idx];
}
}

View file

@ -21,9 +21,9 @@ u64 GetServiceNameLength(u64 service) {
/* Utilities. */
Registration::Process *Registration::GetProcessForPid(u64 pid) {
for (unsigned int i = 0; i < REGISTRATION_LIST_MAX_PROCESS; i++) {
if (g_process_list[i].pid == pid) {
return &g_process_list[i];
for (auto &process : g_process_list) {
if (process.pid == pid) {
return &process;
}
}
return NULL;
@ -33,10 +33,10 @@ Registration::Process *Registration::GetFreeProcess() {
return GetProcessForPid(0);
}
Registration::Service *Registration::GetService(u64 service) {
for (unsigned int i = 0; i < REGISTRATION_LIST_MAX_SERVICE; i++) {
if (g_service_list[i].service_name == service) {
return &g_service_list[i];
Registration::Service *Registration::GetService(u64 service_name) {
for (auto &service : g_service_list) {
if (service.service_name == service_name) {
return &service;
}
}
return NULL;