From 5f2a12b015f957c33a7d8edbd06d2fe3594f8b3b Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 14 Jun 2023 10:52:44 +0300 Subject: Fix find() to avoid redundant checks --- bpkg/package-query.cxx | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'bpkg') diff --git a/bpkg/package-query.cxx b/bpkg/package-query.cxx index ea64e71..9675d97 100644 --- a/bpkg/package-query.cxx +++ b/bpkg/package-query.cxx @@ -191,33 +191,33 @@ namespace bpkg return lrf.load (); } } + } - // Finally, load the complements and prerequisites and check them - // recursively. - // - for (const lazy_weak_ptr& cr: cs) + // Finally, load the complements and prerequisites and check them + // recursively. + // + for (const lazy_weak_ptr& cr: cs) + { + for (const auto& fr: cr.load ()->fragments) { - for (const auto& fr: cr.load ()->fragments) - { - // Should we consider prerequisites of our complements as our - // prerequisites? I'd say not. - // - if (shared_ptr r = - find (fr.fragment.load (), ap, chain, false)) - return r; - } + // Should we consider prerequisites of our complements as our + // prerequisites? I'd say not. + // + if (shared_ptr r = + find (fr.fragment.load (), ap, chain, false)) + return r; } + } - if (prereq) + if (prereq) + { + for (const lazy_weak_ptr& pr: ps) { - for (const lazy_weak_ptr& pr: ps) + for (const auto& fr: pr.load ()->fragments) { - for (const auto& fr: pr.load ()->fragments) - { - if (shared_ptr r = - find (fr.fragment.load (), ap, chain, false)) - return r; - } + if (shared_ptr r = + find (fr.fragment.load (), ap, chain, false)) + return r; } } } -- cgit v1.1