On Jan 17, 2008 4:23 PM, William Uther
<address@hidden> wrote:
On 18/01/2008, at 4:15 AM, Zack Weinberg wrote:
update.cc, function calculate_update_set:
...
bool have_non_suspended_rev = false;
for (set<revision_id>::const_iterator it = candidates.begin();
it !=
candidates.end(); it++)
{
if (!app.get_project().revision_is_suspended_in_branch(*it,
branch))
{
have_non_suspended_rev = true;
break;
}
}
if (!app.opts.ignore_suspend_certs && have_non_suspended_rev)
{
// remove all suspended revisions
base64<cert_value> branch_encoded;
encode_base64(cert_value(branch()), branch_encoded);
suspended_in_branch s(app, branch_encoded);
for(std::set<revision_id>::iterator it = candidates.begin
(); it
!= candidates.end(); it++)
if (s(*it))
candidates.erase(*it);
}
Yes, that is repeating some work. Here is the intention:
If there are any non-suspended update candidates then remove the
suspended
update candidates, otherwise leave all the suspended revs in the
candidate
set.
Couldn't you do that like this? (note: the code under discussion is
the last thing in the function, and "candidates" is its out-argument).
if (app.opts.ignore_suspend_certs)
return;
set<revision_id> active_candidates;
for (set<revision_id>::const_iterator i = candidates.begin();
i != candidates.end(); i++)
if (!app.get_project().revision_is_suspended_in_branch(*i,
branch))
active_candidates.push_back(*i);
if (!active_candidates.empty())
{
// maybe we could just do "candidates = active_candidates;"
here?
candidates.clear();
std::copy(active_candidates.begin(), active_candidates.end(),
candidates);
}