From 3e7d37301a4c3ce68f0f20e702b35e97656108fc Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 23 May 2019 00:26:17 -0400 Subject: 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. --- src/core/hle/service/aoc/aoc_u.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index 5838be3fc..d3e97776b 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp @@ -116,15 +116,15 @@ void AOC_U::ListAddOnContent(Kernel::HLERequestContext& ctx) { const auto current = Core::System::GetInstance().CurrentProcess()->GetTitleID(); std::vector out; - for (size_t i = 0; i < add_on_content.size(); ++i) { - if ((add_on_content[i] & DLC_BASE_TITLE_ID_MASK) == current) { - out.push_back(static_cast(add_on_content[i] & 0x7FF)); - } - } - const auto& disabled = Settings::values.disabled_addons[current]; - if (std::find(disabled.begin(), disabled.end(), "DLC") != disabled.end()) { - out = {}; + if (std::find(disabled.begin(), disabled.end(), "DLC") == disabled.end()) { + for (u64 content_id : add_on_content) { + if ((content_id & DLC_BASE_TITLE_ID_MASK) != current) { + continue; + } + + out.push_back(static_cast(content_id & 0x7FF)); + } } if (out.size() < offset) { -- cgit v1.2.3