# # # patch "project.cc" # from [e36cabaeb25304c08435a3a8aa1ab9c22ed820a7] # to [bff2c8ff7455f6e988707c7cd7627ecf59f1a8c1] # # patch "project.hh" # from [004e43c04a1873b95043b80bb1f2ce9ec7178553] # to [006890147145473431c3da49d6883ea10cd4c200] # # patch "revision.cc" # from [6454a4c8bf1812223adcbb165febb3315465b03d] # to [563793f4cf2d265fafa9ac422ab9adc854448fe0] # # patch "revision.hh" # from [11085059e347c4e47ea631169b70231d3db5a180] # to [eb8fe69255a0e21fcfd1074060f5c6b87b844b5a] # ============================================================ --- project.cc e36cabaeb25304c08435a3a8aa1ab9c22ed820a7 +++ project.cc bff2c8ff7455f6e988707c7cd7627ecf59f1a8c1 @@ -13,6 +13,8 @@ using std::vector; using std::string; using std::set; using std::vector; +using std::multimap; +using std::make_pair; project_t::project_t(app_state & app) : app(app) @@ -26,6 +28,8 @@ project_t::get_branch_list(std::set got; indicator = app.db.get_branches(got); branches.clear(); + multimap inverse_graph_cache; + for (std::vector::iterator i = got.begin(); i != got.end(); ++i) { @@ -33,7 +37,7 @@ project_t::get_branch_list(std::set heads; - get_branch_heads(branch, heads); + get_branch_heads(branch, heads, &inverse_graph_cache); if (!heads.empty()) branches.insert(branch); @@ -50,6 +54,8 @@ project_t::get_branch_list(globish const std::vector got; app.db.get_branches(glob(), got); names.clear(); + multimap inverse_graph_cache; + for (std::vector::iterator i = got.begin(); i != got.end(); ++i) { @@ -57,7 +63,7 @@ project_t::get_branch_list(globish const const branch_name branch(*i); std::set heads; - get_branch_heads(branch, heads); + get_branch_heads(branch, heads, &inverse_graph_cache); if (!heads.empty()) names.insert(branch); @@ -108,7 +114,8 @@ void } void -project_t::get_branch_heads(branch_name const & name, std::set & heads) +project_t::get_branch_heads(branch_name const & name, std::set & heads, + multimap *inverse_graph_cache_ptr) { std::pair > & branch = branch_heads[name]; if (branch.first.outdated()) @@ -123,7 +130,7 @@ project_t::get_branch_heads(branch_name branch.second); not_in_branch p(app, branch_encoded); - erase_ancestors_and_failures(branch.second, p, app); + erase_ancestors_and_failures(branch.second, p, app, inverse_graph_cache_ptr); if (!app.opts.ignore_suspend_certs) { ============================================================ --- project.hh 004e43c04a1873b95043b80bb1f2ce9ec7178553 +++ project.hh 006890147145473431c3da49d6883ea10cd4c200 @@ -35,7 +35,8 @@ public: void get_branch_list(std::set & names); void get_branch_list(globish const & glob, std::set & names); - void get_branch_heads(branch_name const & name, std::set & heads); + void get_branch_heads(branch_name const & name, std::set & heads, + std::multimap *inverse_graph_cache_ptr = NULL); outdated_indicator get_tags(std::set & tags); void put_tag(revision_id const & id, std::string const & name); ============================================================ --- revision.cc 6454a4c8bf1812223adcbb165febb3315465b03d +++ revision.cc 563793f4cf2d265fafa9ac422ab9adc854448fe0 @@ -457,17 +457,21 @@ erase_ancestors_and_failures(std::set & candidates, is_failure & p, - app_state & app) + app_state & app, + multimap *inverse_graph_cache_ptr) { // Load up the ancestry graph multimap inverse_graph; + if (inverse_graph_cache_ptr == NULL) + inverse_graph_cache_ptr = &inverse_graph; + if (inverse_graph_cache_ptr->empty()) { multimap graph; app.db.get_revision_ancestry(graph); for (multimap::const_iterator i = graph.begin(); i != graph.end(); ++i) - inverse_graph.insert(make_pair(i->second, i->first)); + inverse_graph_cache_ptr->insert(make_pair(i->second, i->first)); } // Keep a set of all ancestors that we've traversed -- to avoid @@ -494,7 +498,7 @@ erase_ancestors_and_failures(std::set +#include #include @@ -150,7 +151,8 @@ erase_ancestors_and_failures(std::set & revisions, is_failure & p, - app_state & app); + app_state & app, + std::multimap *inverse_graph_cache_ptr = NULL); void ancestry_difference(revision_id const & a, std::set const & bs,