Skip to content

Conversation

@JackBoosY
Copy link
Contributor

auto cache_status = build_cache_status_vector(actions, m_status);
for (auto&& provider : m_providers)
{
provider->precheck(paths, actions, cache_status);
}

static std::vector<CacheStatus*> build_cache_status_vector(View<Dependencies::InstallPlanAction> actions,
std::unordered_map<std::string, CacheStatus>& status)
{
std::vector<CacheStatus*> results{actions.size()};
for (size_t idx = 0; idx < actions.size(); ++idx)
{
const auto abi = actions[idx].package_abi().get();
if (abi)
{
results[idx] = &status[*abi];
}
}
return results;

m_status maybe empty so cache_status[idx] maybe a nullptr.

@JackBoosY JackBoosY requested a review from BillyONeal January 20, 2022 04:36
Comment on lines +1461 to +1462
results[idx] = cache_status[idx]->get_available_provider() ? CacheAvailability::available
: CacheAvailability::unavailable;
Copy link
Contributor Author

@JackBoosY JackBoosY Jan 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or

Suggested change
results[idx] = cache_status[idx]->get_available_provider() ? CacheAvailability::available
: CacheAvailability::unavailable;
results[idx] = cache_status[idx]
? (cache_status[idx]->get_available_provider() ? CacheAvailability::available
: CacheAvailability::unavailable)
: CacheAvailability::unavailable;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant