service/aoc: Avoid allocating and discarding data

Previously, the code was accumulating data into a std::vector and then
tossing all of it away if a setting was disabled.

Instead, we can just check if it's disabled and do no work at all if
possible. If it's enabled, then we can append to the vector and
allocate.

Unlikely to impact usage much, but it is slightly less sloppy with
resources.
This commit is contained in:
Lioncash 2019-05-23 00:26:17 -04:00
parent d0e200a894
commit 3e7d37301a

View file

@ -116,15 +116,15 @@ void AOC_U::ListAddOnContent(Kernel::HLERequestContext& ctx) {
const auto current = Core::System::GetInstance().CurrentProcess()->GetTitleID(); const auto current = Core::System::GetInstance().CurrentProcess()->GetTitleID();
std::vector<u32> out; std::vector<u32> out;
for (size_t i = 0; i < add_on_content.size(); ++i) { const auto& disabled = Settings::values.disabled_addons[current];
if ((add_on_content[i] & DLC_BASE_TITLE_ID_MASK) == current) { if (std::find(disabled.begin(), disabled.end(), "DLC") == disabled.end()) {
out.push_back(static_cast<u32>(add_on_content[i] & 0x7FF)); for (u64 content_id : add_on_content) {
} if ((content_id & DLC_BASE_TITLE_ID_MASK) != current) {
continue;
} }
const auto& disabled = Settings::values.disabled_addons[current]; out.push_back(static_cast<u32>(content_id & 0x7FF));
if (std::find(disabled.begin(), disabled.end(), "DLC") != disabled.end()) { }
out = {};
} }
if (out.size() < offset) { if (out.size() < offset) {