Removed all for loops from the profile manager

This commit is contained in:
David Marcec 2018-08-11 20:15:59 +10:00
parent c3013c7c9c
commit 662218e997

View File

@ -141,20 +141,15 @@ void ProfileManager::CloseUser(UUID uuid) {
std::array<UUID, MAX_USERS> ProfileManager::GetAllUsers() const { std::array<UUID, MAX_USERS> ProfileManager::GetAllUsers() const {
std::array<UUID, MAX_USERS> output; std::array<UUID, MAX_USERS> output;
for (unsigned i = 0; i < user_count; i++) { std::transform(profiles.begin(), profiles.end(), output.begin(),
output[i] = profiles[i].user_uuid; [](const ProfileInfo& p) { return p.user_uuid; });
}
return output; return output;
} }
std::array<UUID, MAX_USERS> ProfileManager::GetOpenUsers() const { std::array<UUID, MAX_USERS> ProfileManager::GetOpenUsers() const {
std::array<UUID, MAX_USERS> output; std::array<UUID, MAX_USERS> output;
unsigned user_idx = 0; std::copy_if(profiles.begin(), profiles.end(), output.begin(),
for (unsigned i = 0; i < user_count; i++) { [](const ProfileInfo& p) { return p.is_open; });
if (profiles[i].is_open) {
output[i++] = profiles[i].user_uuid;
}
}
return output; return output;
} }